本文整理汇总了Python中Problem.Problem.mostRatings方法的典型用法代码示例。如果您正苦于以下问题:Python Problem.mostRatings方法的具体用法?Python Problem.mostRatings怎么用?Python Problem.mostRatings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem.Problem
的用法示例。
在下文中一共展示了Problem.mostRatings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from Problem import Problem [as 别名]
# 或者: from Problem.Problem import mostRatings [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