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
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
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)
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
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
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)
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)
def get_model(): raw_data = get_moive100k() model = Model(raw_data) return model
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)
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)
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)
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)
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)
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)
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)
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)