Guest User

Untitled

a guest
Oct 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. ratings_pre = []
  2. db = Database()
  3. places = []
  4. formated_ratings = []
  5.  
  6. for i in range(1, (items_length) + 1):
  7. predict = algo.predict(user_id, i, r_ui=4)
  8. if not predict.details['was_impossible']:
  9. dictionary = {
  10. 'user': user_id,
  11. 'item': i,
  12. 'est_rating': float(predict.est)
  13. }
  14. ratings_pre.append(dictionary)
  15.  
  16. for place in ratings_pre:
  17. places.append(db.findByIdPlaces(place['item']))
  18.  
  19. for i in range(len(ratings_pre)):
  20. dict_ = {
  21. "placeId": ratings_pre[i]['item'],
  22. "userId": ratings_pre[i]['user'],
  23. "rate_prevision": ratings_pre[i]['est_rating'],
  24. "name": places[i]["name"],
  25. "photoUrl": places[i]["photoUrl"],
  26. "rate_user": 0,
  27. "algorithm": "SVD"
  28. }
  29. formated_ratings.append(dict_)
  30.  
  31. return formated_ratings
Add Comment
Please, Sign In to add comment