Menu

Adding Average Ratings as a Popularity Signal

Adding Average Ratings as a Popularity Signal

Genre similarity alone is not enough to build good recommendations. User preferences must also be considered. In this lesson, we calculate the average rating for each movie and merge it into the movie dataset.

Code:

avg_ratings = ratings.groupby('movieId')['rating'].mean()

movies = movies.merge(avg_ratings, on='movieId', how='left')

movies['rating'].fillna(0, inplace=True)

The average rating acts as a popularity signal. By including it, the system can prefer movies that users generally like, rather than recommending obscure or poorly rated movies solely based on genre similarity.