コード例 #1
0
ファイル: testmodel.py プロジェクト: peterxugo/weibo
def predictresult(models, traindatestart, traindateend, testdateend):
    data = readdata()
    don, need_train_data = usercluseter(data)

    train_data, don_not_have_before = xandy(
        need_train_data, traindatestart, traindateend, testdateend)

    pymid_and_ys = testp(models, train_data)

    ty = onetimeintveraldata(data, traindateend, testdateend)

    a = pd.merge(pymid_and_ys[0], pymid_and_ys[1],
                 left_index=True, right_index=True, how="outer")
    b = pd.merge(
        a, pymid_and_ys[2], left_index=True, right_index=True, how="outer")
    py = b.fillna(0)

    pyy = ty.copy(deep=True)
    print id(pyy), id(ty)
    # print py.ix[:, :]
    # sys, exit()
    mindex = pyy["mid"].isin(py.index)
    pyy.loc[
        mindex, ["forward_count", "comment_count", "like_count"]] = py.values[3:6]

    # print pyy.loc[~mindex, ["forward_count", "comment_count", "like_count"]]

    pyy.loc[~mindex, ["forward_count", "comment_count", "like_count"]] = 0

    f = pyy.values[:, 3:6]
    t = ty.values[:, 3:6]
    print f, t
    print scores(f, t)
コード例 #2
0
ファイル: testmodel.py プロジェクト: peterxugo/weibo
    ty = onetimeintveraldata(data, traindateend, testdateend)

    a = pd.merge(pymid_and_ys[0], pymid_and_ys[1],
                 left_index=True, right_index=True, how="outer")
    b = pd.merge(
        a, pymid_and_ys[2], left_index=True, right_index=True, how="outer")
    py = b.fillna(0)

    pyy = ty.copy(deep=True)
    print id(pyy), id(ty)
    # print py.ix[:, :]
    # sys, exit()
    mindex = pyy["mid"].isin(py.index)
    pyy.loc[
        mindex, ["forward_count", "comment_count", "like_count"]] = py.values[3:6]

    # print pyy.loc[~mindex, ["forward_count", "comment_count", "like_count"]]

    pyy.loc[~mindex, ["forward_count", "comment_count", "like_count"]] = 0

    f = pyy.values[:, 3:6]
    t = ty.values[:, 3:6]
    print f, t
    print scores(f, t)
    # return pyy, ty

if __name__ == '__main__':
    data = readdata()
    # print type(data)
    traindatestart, traindateend, testdateend = "2014-08-01", "2014-09-01", "2014-10-01"