Ejemplo n.º 1
0
def main_flow():
    user_click = reader.get_user_click("../data/ratings.dat")
    item_info = reader.get_item_info("../data/movies.dat")
    sim_info = cal_item_sim(user_click)
    recom_result = cal_recom_result(sim_info, user_click)

    debug_recomresult(recom_result, item_info)
Ejemplo n.º 2
0
def main_flow():
    """
    main flow of itemcf
    """
    user_click, user_click_time = reader.get_user_click("../data/ratings.csv")
    item_info = reader.get_item_info("../data/movies.csv")
    sim_info = cal_item_sim(user_click, user_click_time)
    debug_itemsim(item_info, sim_info)
Ejemplo n.º 3
0
def main_flow():
    """
    main flow
    """
    user_click,user_click_time = reader.get_user_click("../data/ratings.csv")
    item_info = reader.get_item_info("../data/movies.csv")
    item_click_by_user = transfer_user_click(user_click)
    user_sim = cal_user_sim(item_click_by_user,user_click_time)
    debug_user_sim(user_sim)
Ejemplo n.º 4
0
def main_flow():
    """
    main flow of itemcf
    :return:
    """
    user_click = reader.get_user_click("../data/ratings.csv")
    item_info = reader.get_item_info("../data/movies.csv")
    sim_info = cal_item_sim(user_click)
    # debug_itemsim(item_info,sim_info)
    recom_result = cal_recom_result(sim_info, user_click)
    debug_recomresult(recom_result, item_info)
Ejemplo n.º 5
0
def main_flow():
    """
    main flow
    """
    user_click, user_click_time = reader.get_user_click("../data/ratings.csv")
    item_info = reader.get_item_info("../data/movies.csv")
    item_click_by_user = transfer_user_click(user_click)
    user_sim = cal_user_sim(item_click_by_user, user_click_time)
    debug_user_sim(user_sim)
    recom_result = cal_recom_result(user_click, user_sim)
    # print(recom_result["1"])
    debug_recom_result(item_info, recom_result)
Ejemplo n.º 6
0
def main_flow():
    """
    main flow of item_cf
    """
    user_click, user_click_time = get_user_click(
        '../data/ratings.csv')  # 获得user[item1,item2]
    # 计算item与item直接的相似度
    sim_info = cal_item_sim(user_click, user_click_time)
    # print(sim_info)
    # 计算推荐结果
    recommend_result = cal_recommend_result(sim_info, user_click)

    item_info = get_item_info(
        '../data/movies.csv')  # 获得{movieId:[title, genre]}
    debug_item_sim(item_info, sim_info)
    debug_recommend_result(recommend_result, item_info)
def main_flow():
    """
    1,计算得到item的相似度
    2,根据相似度进行推荐
    3, 计算召回率和准确率
    """

    # 主功能区
    # step1:获得用户的点击序列    【获取到公式升级2的时间差】
    user_click, user_click_time = reader.get_user_click(
        "../data/split/rat_train.txt")

    item_info = reader.get_item_info("../data/movies.txt")

    # step2:根据用户的点击序列,得到Item的相似度
    # sim_info = cal_item_sim(user_click)

    # 【升级2】在计算item的相似度的时候需要用到user_click_time
    sim_info = cal_item_sim(user_click, user_click_time)

    # debug itemsim使用
    debug_itemsim(item_info, sim_info)

    # step3:根据用户的点击序列以及item的sim_info,去计算推荐结果
    recom_result = cal_recom_result(sim_info, user_click)

    # print(recom_result["1"])

    # debug recomresult使用
    debug_recomresult(recom_result, item_info)

    # 计算评测指标(recom_result即是[user,itemid])
    # 1.获取test的用户点击序列
    test_userClick = reader.get_user_click("../data/split/rat_test.txt")[0]

    # 2.进入函数Recall\Precision\Coverage\Populartity
    recall = evaluation.Recall(recom_result, test_userClick)
    precision = evaluation.Precision(recom_result, test_userClick)
    coverage = evaluation.Coverage(recom_result, item_info)
    populartity = evaluation.Populartity(recom_result)

    print("recall(召回率):" + str(recall) + "\t" + "precision(准确率):" +
          str(precision))
    print("coverage(覆盖率):" + str(coverage) + "\t" + "populartity(新颖度):" +
          str(populartity))
def main_flow():
    """
    main_flow
    1,计算用户的相似度矩阵
    2,根据user相似度矩阵给user推荐物品
    """

    # step1:获得用户的点击序列
    user_click, user_click_time = reader.get_user_click(
        "../data/split/rat_train.txt")

    item_info = reader.get_item_info("../data/movies.txt")

    # step2:同一个用户点击的item有哪些,根据此贡献值进行计算,所以需要将user_click转化成item_click_by_user,并计算其相似度
    item_click_by_user = transfer_user_click(user_click)

    # user_sim = cal_user_sim(item_click_by_user)
    # 【公式升级2】中即需要考虑到用户对同一物品点击的时间差,时间差越小,贡献度越高
    user_sim = cal_user_sim(item_click_by_user, user_click_time)

    # debug相似度的函数
    debug_user_sim(user_sim)

    # step3:根据用户的相似度矩阵,及点击序列,即可得到对用户的推荐结果
    recom_result = cal_recom_result(user_click, user_sim)

    # debug推荐结果的函数
    debug_recom_result(item_info, recom_result)

    print(recom_result["1"])

    # 计算评测指标(recom_result即是[user,itemid])
    # 1.获取test的用户点击序列
    test_userClick = reader.get_user_click("../data/split/rat_test.txt")[0]

    # 2.进入函数Recall\Precision\Coverage\Populartity
    recall = evaluation.Recall(recom_result, test_userClick)
    precision = evaluation.Precision(recom_result, test_userClick)
    coverage = evaluation.Coverage(recom_result, item_info)
    populartity = evaluation.Populartity(recom_result)

    print("recall(召回率):" + str(recall) + "\t" + "precision(准确率):" +
          str(precision))
    print("coverage(覆盖率):" + str(coverage) + "\t" + "populartity(新颖度):" +
          str(populartity))
Ejemplo n.º 9
0
def main_flow():
    user_click, user_click_time = reader.get_user_click('../data/ratings.csv')
    item_info = reader.get_item_info('../data/movies.csv')
    sim_info = cal_item_sim(user_click, user_click_time)
    debug_itemsim(item_info, sim_info)