Exemple #1
0
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 "..."
Exemple #2
0
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 "..."
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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)
Exemple #6
0
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)
Exemple #7
0
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)
Exemple #8
0
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) 
Exemple #9
0
                       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)
Exemple #10
0
def create_model():
    raw_data = get_user_item_matrix()
    friend_data = get_friends_data()
    i_model = FriendsModel(raw_data, friend_data)
    return i_model
Exemple #11
0
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()))
Exemple #12
0
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)
Exemple #13
0
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)
Exemple #14
0
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)
Exemple #15
0
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)
Exemple #16
0
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)
Exemple #18
0
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)
Exemple #19
0
def create_model():
    raw_data = get_user_item_matrix()
    friend_data = get_friends_data()
    i_model = FriendsModel(raw_data, friend_data)
    return i_model
Exemple #20
0
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)