def Show_Users_on_10_FMT(): indx = 0 friend_data = get_friends_data() for ky in friend_data: print ky indx += 1 if indx > 20: break print "..."
def Show_Users_on_10_FMT(): indx = 0 friend_data = get_friends_data() for ky in friend_data: print ky indx += 1 if indx > 20: break print "..."
def Generate_Simulating_Data_on_10_FMT(user_id): filelocation = "./FMT10/" friend_data = get_friends_data() raw_data = get_user_item_matrix() generate_simulating_data(raw_data, friend_data, user_id, 30, 10, filelocation)
def JPH_on_10_FMT(): f_s = [10, 20, 30, 40, 50] friend_data = get_friends_data() raw_data = get_user_item_matrix() jhk_friends(raw_data, friend_data, f_s)
def Single_Stranger_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "stranger_dif_10fmt_" single_influence(raw_data, friend_data, False, filename)
def Single_Friend_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "friend_dif_10fmt_" single_influence(raw_data, friend_data, True, filename)
def MAE_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() f_ts = [(10, 10), (20, 10), (30, 10), (40, 10), (50, 10)] calculate_cosine_friends_strangers(raw_data, friend_data, f_ts)
def MAE_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() f_ts = [(10,10),(20,10),(30,10),(40,10),(50,10)] calculate_cosine_friends_strangers(raw_data, friend_data, f_ts)
color='k', marker='>', alpha=0.8, label="friends") plt.title('Cosine Similarity') plt.axis('tight') plt.ylabel("Similarity") plt.xlabel("User ID") plt.legend(loc='lower right') plt.show() if __name__ == '__main__': raw_data = get_user_item_matrix() friend_data = get_friends_data() sim_mat = get_similarity_matrix(raw_data, friend_data) f_sim = get_friends_similarity(sim_mat, friend_data) t_sim = get_strangers_similarity(sim_mat, friend_data) idx = 1 f_sims = {} t_sims = {} for ky in f_sim: f_sims[idx] = f_sim[ky] t_sims[idx] = t_sim[ky] idx += 1 draw_similarity(f_sims, t_sims)
def create_model(): raw_data = get_user_item_matrix() friend_data = get_friends_data() i_model = FriendsModel(raw_data, friend_data) return i_model
def get_args(): return def show_dict(the_dict): total_v = 0.0 for ky in the_dict.keys(): total_v += the_dict[ky] print len(the_dict.keys()) print total_v / len(the_dict.keys()) if __name__ == '__main__': #raw_data = get_original_UI(1)#get_original_user_item_matrix() #get_user_item_matrix() friend_data_1 = get_friends_data() raw_data_1 = get_user_item_matrix() #calculate_jph(raw_data_1,friend_data_1) calculate_cosine_friends_strangers(raw_data_1, friend_data_1) #reputation_data = get_reputation() #calculate_reputation_rmse_friends(raw_data,friend_data,reputation_data) #calculate_reputation_rmse_strangers(raw_data,friend_data,reputation_data) #calculate_nmf_rmse_global(raw_data) #var_arr = calculate_rate_average_global(raw_data,friend_data) #total = 0.0 #for u_id in var_arr.keys(): # var1 = var_arr[u_id] # total += var1 #avg = total/float(len(var_arr.keys()))
def Generate_Simulating_Data_on_10_FMT(user_id): filelocation = "./FMT10/" friend_data = get_friends_data() raw_data = get_user_item_matrix() generate_simulating_data(raw_data,friend_data,user_id,30,10,filelocation)
def JPH_on_10_FMT(): f_s = [10, 20 ,30, 40, 50] friend_data = get_friends_data() raw_data = get_user_item_matrix() jhk_friends(raw_data, friend_data, f_s)
def Single_Stranger_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "stranger_dif_10fmt_" single_influence(raw_data,friend_data,False,filename)
def Single_Friend_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "friend_dif_10fmt_" single_influence(raw_data,friend_data,True,filename)
def get_args(): return def show_dict(the_dict): total_v = 0.0 for ky in the_dict.keys(): total_v+=the_dict[ky] print len(the_dict.keys()) print total_v/len(the_dict.keys()) if __name__ == '__main__': #raw_data = get_original_UI(1)#get_original_user_item_matrix() #get_user_item_matrix() friend_data_1 = get_friends_data() raw_data_1 = get_user_item_matrix() #calculate_jph(raw_data_1,friend_data_1) calculate_cosine_friends_strangers(raw_data_1,friend_data_1) #reputation_data = get_reputation() #calculate_reputation_rmse_friends(raw_data,friend_data,reputation_data) #calculate_reputation_rmse_strangers(raw_data,friend_data,reputation_data) #calculate_nmf_rmse_global(raw_data) #var_arr = calculate_rate_average_global(raw_data,friend_data) #total = 0.0 #for u_id in var_arr.keys(): # var1 = var_arr[u_id] # total += var1 #avg = total/float(len(var_arr.keys()))
plt.axis('tight') plt.show() def show_statistic(ivector): sumx = {} for item in ivector: if item in sumx: sumx[item] += 1 else: sumx[item] = 1 colors = list("rgbcmyk") plt.scatter(sumx.keys(),sumx.values(),color=colors.pop()) plt.legend(sumx.keys()) plt.show() def run_single_influence(raw_data, friend_data): f_n = 10 t_n = 11 ratio = 0.8 esvlidation = EsoricsSingleUserValidation(5,raw_data,friend_data,f_n,t_n,ratio) results = esvlidation.cross_validate() return results if __name__ == '__main__': friend_data = get_friends_data() raw_data = get_user_item_matrix() results = run_single_influence(raw_data,friend_data) show_data(results)
def Pure_Friend_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "pure_friend_dif_10fmt_" pure_single_friend_influence(raw_data, friend_data, filename)
def create_model(): raw_data = get_user_item_matrix() friend_data = get_friends_data() i_model = FriendsModel(raw_data, friend_data) return i_model
def Pure_Friend_Influence_on_10_FMT(): friend_data = get_friends_data() raw_data = get_user_item_matrix() filename = "pure_friend_dif_10fmt_" pure_single_friend_influence(raw_data,friend_data,filename)