Update collaborative-filtering.md

Add extra output to show `ratings_agg_df` values.
This commit is contained in:
Daniel Romero
2024-06-25 12:34:50 -03:00
committed by GitHub
parent 3f99e8ff78
commit 68a5d4bafb
@@ -99,8 +99,18 @@ merged_df = ratings_df.merge(movies_df[['movieId', 'title']], left_on='movieId',
# Aggregate ratings to handle duplicate (userId, title) pairs
ratings_agg_df = merged_df.groupby(['userId', 'movieId']).rating.mean().reset_index()
ratings_agg_df.head()
```
| |userId |movieId |rating|
|---|---|---|---|
|0 |1 |1 |0.429960|
|1 |1 |1036 |1.369846|
|2 |1 |1049 |-0.509926|
|3 |1 |1066 |0.429960|
|4 |1 |110 |0.429960|
### Convert to sparse
If you want to search across numerous reviews from different users, you can represent these reviews in a sparse matrix.