Mercurial > hg > hybrid-music-recommender-using-content-based-and-social-information
comparison Code/content_based.py @ 27:ae650489d3a8
Updated report
author | Paulo Chiliguano <p.e.chiilguano@se14.qmul.ac.uk> |
---|---|
date | Sun, 30 Aug 2015 15:49:27 +0100 |
parents | e4bcfe00abf4 |
children |
comparison
equal
deleted
inserted
replaced
26:e4bcfe00abf4 | 27:ae650489d3a8 |
---|---|
110 else: | 110 else: |
111 if rating > rating_threshold: | 111 if rating > rating_threshold: |
112 fn += 1 | 112 fn += 1 |
113 elif rating <= rating_threshold: | 113 elif rating <= rating_threshold: |
114 tn += 1 | 114 tn += 1 |
115 print tp, fp, fn, tn | 115 #print tp, fp, fn, tn |
116 if tp != 0: | 116 if tp != 0: |
117 precision = tp / (tp + fp) | 117 precision = tp / (tp + fp) |
118 recall = tp / (tp + fn) | 118 recall = tp / (tp + fn) |
119 F1 = 2 * precision * recall / (precision + recall) | 119 F1 = 2 * precision * recall / (precision + recall) |
120 else: | 120 else: |
136 start_time = time.time() | 136 start_time = time.time() |
137 sim_matrix = build_model_cb(users_train[i]) | 137 sim_matrix = build_model_cb(users_train[i]) |
138 | 138 |
139 topN = {} | 139 topN = {} |
140 for user, song_rating in users_train[i].iteritems(): | 140 for user, song_rating in users_train[i].iteritems(): |
141 topN[user] = top_n(sim_matrix, user, song_rating) | 141 topN[user] = top_n(sim_matrix, user, song_rating, rating_threshold=2, N=20) |
142 elapsed_time = time.time() - start_time | 142 elapsed_time = time.time() - start_time |
143 print 'Training execution time: %.3f seconds' % elapsed_time | 143 print 'Training execution time: %.3f seconds' % elapsed_time |
144 | 144 |
145 pi, ri, fi, ai = evaluate_cb(topN, users_test[i]) | 145 pi, ri, fi, ai = evaluate_cb(topN, users_test[i]) |
146 | 146 |