本文整理匯總了Python中Problem.Problem.loadline方法的典型用法代碼示例。如果您正苦於以下問題:Python Problem.loadline方法的具體用法?Python Problem.loadline怎麽用?Python Problem.loadline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Problem.Problem
的用法示例。
在下文中一共展示了Problem.loadline方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1:
# 需要導入模塊: from Problem import Problem [as 別名]
# 或者: from Problem.Problem import loadline [as 別名]
import csv
from Problem import Problem
reader=csv.reader(file("Assignment 3.csv","rb"))
problem=Problem()
index=0
for row in reader:
problem.loadline(row,index)
index+=1
# print problem.users
# print problem.movies
# print problem.matrix
#Without Normalization
problem.computecorelation()
problem.calcuNearneibor()
#test 3712(7th)
#problem.predict(6)
#predict movies for 3867(5th) and 89(14th)
problem.predict(4)
problem.predict(13)
#Normalization
problem.predictnormalized(4)
problem.predictnormalized(13)
示例2:
# 需要導入模塊: from Problem import Problem [as 別名]
# 或者: from Problem.Problem import loadline [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