Guest User

Untitled

a guest
Nov 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. movieId userId rating
  2. 1 1 1.0
  3. 1 2 4.5
  4. 1 5 5.0
  5. 1 8 5.0
  6. 1 10 5.0
  7. 2 1 2.0
  8. 2 3 4.5
  9. 2 5 5.0
  10. 2 6 3.0
  11. 2 8 4.0
  12.  
  13. {
  14. 0:[1.0, 4.5, 0.0, 0.0, 5.0, 0.0, 0.0, 5.0, 0.0, 5.0]
  15. 1:[2.0, 0.0, 4.5, 0.0, 5.0, 3.0, 0.0, 4.0, 0.0, 0.0]
  16. }
  17.  
  18. def build_rating_vector_for_movie(movie_id, num_users):
  19. rating_vector = [0] * num_users
  20. movie_group = user_rating_by_movie.get_group(movie_id)
  21.  
  22. for u, r in zip(movie_group.userId.values, movie_group.rating.values):
  23. rating_vector[u - 1] = r
  24.  
  25. movie_user_ratings[movie_id] = rating_vector
Add Comment
Please, Sign In to add comment