本文整理匯總了Python中Problem.Problem.meanRatings方法的典型用法代碼示例。如果您正苦於以下問題:Python Problem.meanRatings方法的具體用法?Python Problem.meanRatings怎麽用?Python Problem.meanRatings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Problem.Problem
的用法示例。
在下文中一共展示了Problem.meanRatings方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1:
# 需要導入模塊: from Problem import Problem [as 別名]
# 或者: from Problem.Problem import meanRatings [as 別名]
import csv
from Problem import Problem
reader = csv.reader(open("A1Ratings.csv","rU"))
problem=Problem()
for row in reader:
problem.loadline(row)
average_ratings=dict(zip(problem.movienames,[('%.2f')%f for f in problem.meanRatings()]))
average_ratings=sorted(average_ratings.iteritems(),key=lambda d:d[1], reverse=True)
print average_ratings
most_ratings=dict(zip(problem.movienames,[f for f in problem.mostRatings()]))
most_ratings=sorted(most_ratings.iteritems(),key=lambda d:d[1],reverse=True)
print most_ratings
higher_ratings=dict(zip(problem.movienames,[('%.2f')%f for f in problem.rating4()]))
higher_ratings=sorted(higher_ratings.iteritems(),key=lambda d:d[1],reverse=True)
print higher_ratings
rel=dict(zip(problem.movienames[1:],[('%.2f')%f for f in problem.getRelevance()]))
rel=sorted(rel.iteritems(),key=lambda d:d[1],reverse=True)
print rel