コード例 #1
0
__author__ = "ponomarevandrew"

import recs
import dataModel
import numpy as np


dirs = ["BC"]

for dir in dirs:
    prefs_test, data_test, matrix_test = dataModel.loadMovielens("/u1.test", matrix=dir)
    b_u = np.loadtxt(dir + "/b_u.txt")
    b_v = np.loadtxt(dir + "/b_v.txt")
    u_f = np.loadtxt(dir + "/u_f.txt")
    v_f = np.loadtxt(dir + "/v_f.txt")
    f = open(dir + "/mu.txt", "r")
    mu = float(f.read())

    mae = recs.maeSVD(prefs_test, mu, b_u, b_v, u_f, v_f)
    f = open(dir + "/mae_stoch_svd.txt", "w")
    f.write(str(mae))

print "!233131"
コード例 #2
0
__author__ = 'ponomarevandrew'

import dataModel
import recs
import numpy as np

a = np.arange(111)
np.savetxt("A/sims.txt", a)
b = np.loadtxt("A/sims.txt")

dirs = ["A","C","BC"]

for dir in dirs:

    prefs,data,matrix = dataModel.loadMovielens('/u1.base',matrix = dir)

    #matrix_A = recs.get_similarity_matrix(matrix, method ='knn' )
    #np.savetxt(dir+"/sims_knn_user.txt",matrix_A)
    matrix_B = recs.get_similarity_matrix(matrix, method ='knn_svd' )
    np.savetxt(dir+"/sims_knn_svd.txt",matrix_B)
    matrix_C = recs.get_similarity_matrix(matrix, method ='knn_nmf' )
    np.savetxt(dir+"/sims_knn_nmf.txt",matrix_C)
    #matrix_D = recs.get_similarity_matrix(matrix, method ='knn_item' )
    #np.savetxt(dir+"/sims_knn_item.txt",matrix_D)

print 'aaaaa'
コード例 #3
0
__author__ = 'ponomarevandrew'


import recs
import dataModel
import numpy as np

dirs = ["A","BC","C"]
names = ["knn_user", "knn_svd" , "knn_nmf", "knn_item"]

for dir in dirs:
    for name in names:
        prefs_trainig,data,matrix_training = dataModel.loadMovielens('/u1.base',matrix=dir)
        prefs_test, data_test, matrix_test = dataModel.loadMovielens('/u1.test',matrix=dir)
        sim_matrix = np.loadtxt(dir+ "/sims_"+ name + ".txt")
        mae = recs.mae(prefs_test,prefs_trainig,sim_matrix)
        f = open(dir +'/mae_' + name, 'w')
        f.write(str(mae))


print "Aaaa"