75 val new_ratings = m + (id -> (mov :: old_ratings)) |
75 val new_ratings = m + (id -> (mov :: old_ratings)) |
76 groupById(rest, new_ratings) |
76 groupById(rest, new_ratings) |
77 } |
77 } |
78 } |
78 } |
79 |
79 |
|
80 // |
|
81 //val ls = List(("1", "a"), ("2", "a"), ("1", "c"), ("2", "a"), ("1", "c")) |
|
82 // |
|
83 //val m = groupById(ls, Map()) |
|
84 // |
|
85 //m.getOrElse("1", Nil).count(_ == "c") // => 2 |
|
86 //m.getOrElse("1", Nil).count(_ == "a") // => 1 |
|
87 |
80 // test cases |
88 // test cases |
81 //val ratings_map = groupById(good_ratings, Map()) |
89 //val ratings_map = groupById(good_ratings, Map()) |
|
90 //groupById(good_ratings, Map()).get("214") |
|
91 //groupById(good_ratings, Map()).toList.minBy(_._2.length) |
82 //val movies_map = movie_names.toMap |
92 //val movies_map = movie_names.toMap |
83 |
93 |
84 //ratings_map.get("414").get.map(movies_map.get(_)) // most prolific recommender with 1227 positive ratings |
94 //ratings_map.get("414").get.map(movies_map.get(_)) // most prolific recommender with 1227 positive ratings |
85 //ratings_map.get("474").get.map(movies_map.get(_)) // second-most prolific recommender with 787 positive ratings |
95 //ratings_map.get("474").get.map(movies_map.get(_)) // second-most prolific recommender with 787 positive ratings |
86 //ratings_map.get("214").get.map(movies_map.get(_)) // least prolific recommender with only 1 positive rating |
96 //ratings_map.get("214").get.map(movies_map.get(_)) // least prolific recommender with only 1 positive rating |