Example #1
0
    temp_data3, time_slice, train3 = init_data3(time_slice, train, region, filter_count)
    axis_pois3, axis_users3, train_structure_data3, recommends3, unknow_poi_set3 = preprocess3(temp_data3, time_slice, train3, order)
    tensor3 = trans3(train_structure_data3, order, len(axis_pois3), len(axis_users3), time_slice)
    U3, S3, D3 = HOSVD(numpy.array(tensor3), 0.7)
    A3 = reconstruct(S3, U3)

    x_values = []
    y_values1 = []
    y_values2 = []
    y_values3 = []
    y_values4 = []
    while top_k <= 10:
        avg_precision, avg_recall, avg_f1_score, availability = recommend(A, recommends, unknow_poi_set, time_slice, top_k, order)
        print "avg_recall(pmpt): ", avg_recall

        avg_precision2, avg_recall2, avg_f1_score2, availability2 = recommend2(A2, recommends2, unknow_poi_set2, time_slice, top_k, order)
        print "avg_recall(fmc): ", avg_recall2

        avg_precision3, avg_recall3, avg_f1_score3, availability3 = recommend3(A3, recommends3, unknow_poi_set3, time_slice, top_k, order)
        print "avg_recall(tf): ", avg_recall3

        y_values1.append(avg_recall)
        y_values2.append(avg_recall2)
        y_values3.append(avg_recall3)
        # y_values4.append(availability)
        x_values.append(top_k)
        top_k += 1

    pylab.plot(x_values, y_values1, 'rs', linewidth=1, linestyle="-", label=u"PMPT")
    pylab.plot(x_values, y_values2, 'gs', linewidth=1, linestyle="-", label=u"FMC")
    pylab.plot(x_values, y_values3, 'bs', linewidth=1, linestyle="-", label=u"TF")
Example #2
0
    tensor3 = trans3(train_structure_data3, order, len(axis_pois3),
                     len(axis_users3), time_slice)
    U3, S3, D3 = HOSVD(numpy.array(tensor3), 0.7)
    A3 = reconstruct(S3, U3)

    x_values = []
    y_values1 = []
    y_values2 = []
    y_values3 = []
    y_values4 = []
    while top_k <= 10:
        avg_precision, avg_recall, avg_f1_score, availability = recommend(
            A, recommends, unknow_poi_set, time_slice, top_k, order)
        print "avg_recall(pmpt): ", avg_recall

        avg_precision2, avg_recall2, avg_f1_score2, availability2 = recommend2(
            A2, recommends2, unknow_poi_set2, time_slice, top_k, order)
        print "avg_recall(fmc): ", avg_recall2

        avg_precision3, avg_recall3, avg_f1_score3, availability3 = recommend3(
            A3, recommends3, unknow_poi_set3, time_slice, top_k, order)
        print "avg_recall(tf): ", avg_recall3

        y_values1.append(avg_recall)
        y_values2.append(avg_recall2)
        y_values3.append(avg_recall3)
        # y_values4.append(availability)
        x_values.append(top_k)
        top_k += 1

    pylab.plot(x_values,
               y_values1,