A simple item-based collaborative-filtering movie recommender built with pandas and the MovieLens dataset. Given a few movies a user has rated, it surfaces other movies that similar viewers also liked.
- Load
ratings.csvandmovies.csvand merge onmovieId. - Pivot into a user × movie ratings table.
- Drop movies with fewer than 10 ratings (too noisy) and fill the rest with 0.
- Compute a Pearson correlation matrix between every pair of movies.
- Given a list of
(movie_title, user_rating)tuples, weight each movie's correlation column by(rating - 2.5)— positive for liked, negative for disliked — and sum across all input movies to score candidates.
Result: the top-scoring movies are the recommendations.
Uses the MovieLens small dataset (included in dataset/):
movies.csv— movie IDs and titlesratings.csv— user ratings (0.5–5 stars)tags.csv,links.csv— unused by this script
- Python 3
pandasscipy
pip install pandas scipypython temp.pyTwo demo profiles are baked in — a "romantic_lover" and an "action_lover" preference list — both print their top-20 recommended movies. Edit the lists at the bottom of temp.py to try your own.