Netflix - #!/usr/bin/env python import RMSE, math, sys from...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/usr/bin/env python import RMSE, math, sys from RMSE import rmse userDict = {} movieDict = {} movieRatingDict = {} userDecadeDict = {} probeDict = {} decadeDict = {} predicted = [] actual = [] def computeRMSE(): """ Compute the root mean square error of the actual and expected ratings. """ global predicted global actual print actual print predicted return rmse(tuple(actual), tuple(predicted)) def netflix_read (filename) : """ Read a movie .txt file. Returns a list of all lines in that one movie file, first element is the ID of the movie itself """ assert type(filename) is str data = [] data = open(filename).readlines() assert type(data) is list assert type(data[1]) is str return data def netflix_write (results) : """ Writes each movie ID and rating into a file, 1 line per movie id and it's rating """ assert type(results) is list outFile = "RunNetlix.out" FILE = open(outFile, "w") FILE.writelines(results) FILE.close() def netflix_eval (probeData) : """ Compute the predicted rating of each customer per movie and return a list of predicted movie ratings """ global decadeDict global userDecadeDict global userDict i = 0 tempMovieID = 0 returnList = [] while i < len(probeData):
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if probeData[i][-2] == ":": tempMovieID = int(probeData[i][ : -2])
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/05/2010 for the course CS 373 taught by Professor Downing,glennp during the Fall '08 term at University of Texas at Austin.

Page1 / 5

Netflix - #!/usr/bin/env python import RMSE, math, sys from...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online