Commit 751138f6 authored by RISHABH GARG's avatar RISHABH GARG

Movies to watch

parent 4f8d298d
......@@ -38,3 +38,21 @@ for i in reviewdic:
stdRev=sqrt((sum(map(lambda x: x*x,temp))/len(temp))-mean)
pear.append(sum([(float(prefdict[j])-avgUser)*(float(i[j])-mean)/(len(var)*stdRev*stdUser) for j in var]))
order_pear=sorted(zip(reviewers,pear), key=lambda x:x[1], reverse=True)
unwatched_movies=[i for i in prefdict.keys() if float(prefdict[i])==-1]
finalrating = {}
for movie in header[1:]:
var=[pear[i]*float(reviewdic[i][movie]) for i in range(len(pear)) if float(reviewdic[i][movie])!=-1 and float(prefdict[movie])!=-1]
finalrating[movie]=sum(var)
finalorder = sorted(finalrating.items(), key=lambda x: x[1], reverse = True)
towatch = []
for movie,rating in finalorder:
if movie not in unwatched_movies:
continue
else:
towatch.append(movie)
if len(towatch)>=3:
for i in range(3):
print (towatch[i])
else:
for movie,rating in finalorder:
print (movie)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment