Ejemplo n.º 1
0
def get_moive100k_acc_cv():
    raw_data = get_moive100k()
    mtrs = get_metrics_methods()
    jkx = JphKfold(5, raw_data, metrics=mtrs)
    mscore = jkx.cross_validate()
    print mscore
    return
Ejemplo n.º 2
0
def  get_moive100k_acc_cv():
    raw_data = get_moive100k()
    mtrs = get_metrics_methods()
    jkx = JphKfold(5,raw_data,metrics=mtrs)
    mscore = jkx.cross_validate()
    print mscore
    return
Ejemplo n.º 3
0
def Generate_Simulating_Data_on_MovieLens(user_id):
    user_id = int(user_id)

    filelocation = "./ML100K/"
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    generate_simulating_data(raw_data,friend_data,user_id,70,10,filelocation)
Ejemplo n.º 4
0
def get_friends_from_ml100k():
    dst_file = "./src/dataset/movie100k/ml100kfriend.dat"
    if path.isfile(dst_file):
        friend_data = pickle.load(open(dst_file, "rb"))
        return friend_data

    raw_data = get_moive100k(True)
    raw_model = Model(raw_data)
    cosine_sim = CosineSimilarity(raw_model)
    friend_data = {}

    for user_id in raw_model.get_user_ids():
        neighbors = cosine_sim.get_similarities(user_id)[:250]
        user_ids, x = zip(*neighbors)
        user_ids = list(user_ids)
        shuffle(user_ids)
        # note:
        # Randomly choose 150 out of 250 neighbors as friends.
        # In such case, systems is able to (possiblly) choose strangers which
        # are in top-250 similar users, but with a probability slightly
        # smaller than friends selection.
        friend_data[user_id] = user_ids[:150]

    pickle.dump(friend_data, open(dst_file, "w"), protocol=2)
    return friend_data
Ejemplo n.º 5
0
def get_friends_from_ml100k():
    dst_file = "./src/dataset/movie100k/ml100kfriend.dat"
    if path.isfile(dst_file):
        friend_data = pickle.load(open(dst_file, "rb"))
        return friend_data

    raw_data = get_moive100k(True);
    raw_model = Model(raw_data);
    cosine_sim = CosineSimilarity(raw_model)
    friend_data = {}

    for user_id in raw_model.get_user_ids():
        neighbors = cosine_sim.get_similarities(user_id)[:250]
        user_ids, x = zip(*neighbors)
        user_ids = list(user_ids)
        shuffle(user_ids)
        # note: 
        # Randomly choose 150 out of 250 neighbors as friends.
        # In such case, systems is able to (possiblly) choose strangers which 
        # are in top-250 similar users, but with a probability slightly
        # smaller than friends selection.
        friend_data[user_id] = user_ids[:150] 

    pickle.dump(friend_data,open(dst_file, "w"),protocol=2)
    return friend_data
Ejemplo n.º 6
0
def Generate_Simulating_Data_on_MovieLens(user_id, f_num, t_num):
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    friend_model = FriendsModel(raw_data, friend_data)
    cosine_sim = CosineSimilarity(friend_model)
    fs = Friends_Strangers(cosine_sim, f_num, t_num)
    friends = fs.get_rand_friends(user_id)
    strangers = fs.get_rand_strangers(user_id)
Ejemplo n.º 7
0
def Generate_Simulating_Data_on_MovieLens(user_id,f_num, t_num):
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    friend_model = FriendsModel(raw_data,friend_data)
    cosine_sim = CosineSimilarity(friend_model)
    fs = Friends_Strangers(cosine_sim, f_num, t_num)
    friends = fs.get_rand_friends(user_id)
    strangers = fs.get_rand_strangers(user_id)
Ejemplo n.º 8
0
def get_model():
    raw_data = get_moive100k()
    model = Model(raw_data)
    return model
Ejemplo n.º 9
0
def JPH_on_MovieLens():
    f_s = [20, 40, 60, 80, 100]
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    jhk_friends(raw_data, friend_data, f_s)
Ejemplo n.º 10
0
def Single_Stranger_Influence_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    filename = "friend_dif_ml_"
    single_influence(raw_data, friend_data, False, filename)
Ejemplo n.º 11
0
def MAE_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    f_ts = [(10, 10), (20, 10), (30, 10), (40, 10), (50, 10), (60, 10),
            (70, 10), (80, 10), (90, 10), (100, 10)]
    calculate_cosine_friends_strangers(raw_data, friend_data, f_ts)
Ejemplo n.º 12
0
def Pure_Friend_Influence_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    filename = "pure_friend_dif_ml_"
    pure_single_friend_influence(raw_data, friend_data, filename)
Ejemplo n.º 13
0
def get_model():
    raw_data = get_moive100k()
    model = Model(raw_data)
    return model
Ejemplo n.º 14
0
def Pure_Friend_Influence_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    filename = "pure_friend_dif_ml_"
    pure_single_friend_influence(raw_data,friend_data,filename)
Ejemplo n.º 15
0
def JPH_on_MovieLens():
    f_s = [20, 40 ,60, 80, 100]
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    jhk_friends(raw_data, friend_data, f_s)
Ejemplo n.º 16
0
def Single_Stranger_Influence_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    filename = "friend_dif_ml_"
    single_influence(raw_data,friend_data,False,filename)
Ejemplo n.º 17
0
def MAE_on_MovieLens():
    friend_data = get_friends_from_ml100k()
    raw_data = get_moive100k()
    f_ts = [(10,10),(20,10),(30,10),(40,10),(50,10),(60,10),(70,10),(80,10),(90,10),(100,10)]
    calculate_cosine_friends_strangers(raw_data, friend_data, f_ts)