Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. from mrjob.job import MRJob
  2.  
  3. class MRRatingCounter(MRJob):
  4. def mapper(self, key, line):
  5. (userID, movieID, rating, timestamp) = line.split("t")
  6. yield rating, 1
  7.  
  8. def reducer(self, rating, occurences):
  9. yield rating, sum(occurences)
  10.  
  11. if __name__ == "main__":
  12. MRRatingCounter.run()
  13.  
  14. filepath = "01.ml-100k/u.data"
  15.  
  16. MRRatingCounter(filepath)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement