Skip to content
tkdyun.xyz

Item-Based Recommend System

Collaborative filtering with genre + year ensemble similarity

Machine Learning

Year
2025
Role
Team • Lead • 4
Stack
Python · Pandas · NumPy · Scikit-learn
View on GitHub

Overview

An item-based collaborative filtering recommendation system built from cosine similarity and user-item matrix factorization on MovieLens-scale data. The key improvement over standard CF is an ensemble similarity matrix that incorporates not only user ratings but also movie genres and release years.

Phase 1 — data preprocessing

I worked with four main datasets: movies.csv, ratings.csv,tags.csv, and links.csv.

Handling Missing Genres

34 movies had (no genres listed). Rather than dropping them, I manually filled in genres by cross-referencing TMDB/IMDb to ensure genre-based similarity calculations had complete information.

Resolving Duplicated Movie Titles

For duplicated titles (e.g., Emma (1996), War of the Worlds (2005)), I unified genres using set union, retained the most comprehensive entry, and mapped all movieId references across datasets to preserve user interactions.

Extracting Release Years

Missing release years were imputed via imdbId from the links file. A separate year column was extracted via regex, yielding a heavily cleaned title_only column.

Phase 2 — feature engineering

Rating Standardization (Mean Centering)

To remove user rating bias, I applied User Mean Centering: each user's average rating was subtracted from their individual ratings, then scaled by their standard deviation.

Weighted Rating Adjustments

To address the long-tail problem, I applied a weighted rating formula:

Weighted Avg = (C / (C + T)) * R + (T / (C + T)) * M

C = Number of ratings the movie received
T = Threshold (90th percentile of rating counts)
R = Movie's average rating
M = Overall mean rating

The Ensemble Similarity Matrix

The final similarity matrix is a weighted combination of three cosine similarity calculations:

Total Similarity = (w1 * mat1 + w2 * mat2 + w3 * mat3) / sum(weights)

mat1: Rating-based Cosine Similarity
mat2: Genre-based Cosine Similarity
mat3: Year-based Cosine Similarity

Phase 3 — evaluation

Hyperparameter Tuning via Grid Search

Grid search over weight combinations (w1, w2, w3) from 0.0 to 1.0 in 0.05 steps, evaluating via RMSE on a held-out test set.

Conclusion

By integrating genre and release year metadata alongside robust rating normalization, the ensemble similarity matrix outperforms standard CF. The modular setup allows easy scaling of the importance of rating behavior against content attributes.

Search the site

Choose a destination, or type to search.