Ejemplo n.º 1
0
    else:
        min_occ_user = 35
        min_occ_prog = 300
        leave_k_out = 10
        # perform leave k out.

    top_n = 10
    # performance computed on top N;

    # number of repetitions.
    total_iteration = 3

    # recommendation algorithms
    method_list = [ LMaFit(latent_factor=lafactor), RandUV(latent_factor=lafactor), \
                   HierLat(latent_factor=lafactor), NMF(latent_factor=lafactor),
                   PMF(latent_factor=lafactor),     TriUHV(latent_factor=lafactor)  ]

    #method_list = [ NMF(latent_factor=lafactor),\
    #               PMF(latent_factor=lafactor),     TriUHV(latent_factor=lafactor)  ];

    # main method.
    result = experiment_leave_k_out(exp_name, daily_data_file, min_occ_user, min_occ_prog, \
                method_list,  leave_k_out, total_iteration, top_n, True)

    # display results (average RMSE).
    for method_name, method_iter_perf in result.items():
        print 'Method: ' + method_name
        print '>>Average precision : %.5f' % (sum(x['prec']
                                                  for x in method_iter_perf) /
                                              len(method_iter_perf))
        print '>>Average recall    : %.5f' % (sum(x['recall']
Ejemplo n.º 2
0
    feedback_data.normalize_row()

    # build model with 3 latent factors.
    r = 5
    # the L_2 norm regularizer
    lamb = 0.2
    # the stopping delta value
    delta = 0.01
    # the maximium iteration number
    maxiter = 500

    #     TriUHV_model = TriUHV(r,lamb,delta,maxiter, verbose = True);
    #     TriUHV_model.train(feedback_data);
    '''    
    # test. 
    loc_row = [200,   4, 105];
    loc_col = [ 10,  22,   4];
    print 'Prediction:'
    print TriUHV_model.predict(loc_row, loc_col);
    '''

    # test cold start.
    row = [0, 0, 1, 1, 2, 3, 3]
    col = [0, 3, 1, 4, 0, 1, 3]
    data = [1, 1, 1, 1, 1, 1, 1]

    [f1, f2] = feedback_data.blind_k_out([1])

    LMaFit_model = TriUHV(r, lamb, delta, 5, verbose=True)
    LMaFit_model.train(f1)
Ejemplo n.º 3
0
    # the L_2 norm regularizer 
    lamb = 0.2; 
    # the stopping delta value 
    delta = 0.01;
    # the maximium iteration number
    maxiter = 500;
     
#     TriUHV_model = TriUHV(r,lamb,delta,maxiter, verbose = True); 
#     TriUHV_model.train(feedback_data);
    
    '''    
    # test. 
    loc_row = [200,   4, 105];
    loc_col = [ 10,  22,   4];
    print 'Prediction:'
    print TriUHV_model.predict(loc_row, loc_col);
    '''
        
    # test cold start.
    row =  [0, 0, 1, 1, 2, 3, 3];
    col =  [0, 3, 1, 4, 0, 1, 3];
    data = [1, 1, 1, 1, 1, 1, 1];
     
    [f1, f2] = feedback_data.blind_k_out([1]);
    
    LMaFit_model = TriUHV(r,lamb,delta,5, verbose = True);
    LMaFit_model.train(f1);