本文整理汇总了Python中evaluator.Evaluator.diversityEILD方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluator.diversityEILD方法的具体用法?Python Evaluator.diversityEILD怎么用?Python Evaluator.diversityEILD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evaluator.Evaluator
的用法示例。
在下文中一共展示了Evaluator.diversityEILD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import diversityEILD [as 别名]
#TODO clean this interface!
item_ids = list(set(training_items.keys() + test_items.keys())) #all unique items in the dataset
hits = 0
div_metric1 = []
div_metric2 = []
recommended_ratings = []
for u in test_users.keys():
for i in test_users[u].keys():
user_items = []
if u in training_users:
user_items = training_users[u].keys()
if u in test_users:
user_items += test_users[u].keys()
items_for_cremonesi_validation = testing.choose_some_items(item_ids, user_items, i, 40)
ratings = recommender.get_ratings(u, items_for_cremonesi_validation)
recommendations = ranker.topRatings(ratings)
#recommendations = ranker.maximizeKGreatItems(1, ratings, training_items)
recommended_ratings += ev.totalOfRatings(u, recommendations)
hits += ev.hadAHit(recommendations, i)
div_metric1.append(ev.simpleDiversity(recommendations, training_items))
div_metric2.append(ev.diversityEILD(recommendations, training_items))
test_size = 3191.0
print 'rec', hits/test_size, 'prec', hits/(test_size * N)
print 'sim simple', sum(div_metric1)/len(div_metric1)
print 'div vargas', sum(div_metric2)/len(div_metric2)