Movie Recommendation Engine
Build a movie recommender in Python: you type a movie you liked and get a list of similar movies, based on their genres, cast, director and plot description. It uses a classic technique called TF-IDF, which turns each movie's text into numbers that highlight its distinctive words, then cosine similarity to find the movies whose numbers are closest. No user ratings are needed. You'll work with a public movie dataset, clean it with pandas, build the model with scikit-learn, handle typos in movie titles, and test how different weightings of genre, cast and plot change the results. You'll learn text vectorization, similarity search, fuzzy matching, and organizing a machine learning script into a reusable module.
- Estimate
- ~10.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
pandas · scikit-learn
Project roadmap
- 01
Load and prepare the data
~2hDownload a public movie metadata dataset (for example the TMDB 5000 dataset from Kaggle). Load it with pandas, parse the genres, cast and crew columns (they're stored as JSON text), keep the top 3 actors and the director, remove movies without an overview, and drop duplicates. Join multi-word names into single tokens (Tom Hanks becomes tomhanks) so they count as one feature. Done when: you have a clean table with title, year, genres, cast, director and overview.
- 02
Turn text into vectors
~1.5hBuild one text per movie from its genres, cast, director and overview. Use scikit-learn's TfidfVectorizer with English stop words removed and a limit on the vocabulary, and look at the shape of the resulting matrix and the top-weighted words for a few movies. Done when: the matrix is built, and the top words for a known movie make sense.
- 03
Recommend similar movies
~2hWrite recommend(title, n=10) that finds the movie's row, calculates cosine similarity between it and all others (use linear_kernel on the TF-IDF matrix, which avoids building the full similarity table in memory), and returns the top n other movies with their similarity score, year and genres. Done when: recommendations for a few well-known movies look sensible.
- 04
Build the command line
~1.5hBuild a CLI with argparse: recommend "Movie title" --n 10. Match titles ignoring case, and when there's no exact match, suggest the closest titles using difflib.get_close_matches. When several movies share a title, let the user pick by year. Save the fitted vectorizer and matrix with joblib so the CLI starts quickly. Done when: typing a title with a typo suggests the right movie, and results print in a readable table.
- 05
Tune and evaluate
~2hBuild separate TF-IDF matrices for genres and cast, director and overview, and combine their similarities with weights (for example 0.4, 0.3 and 0.3). Compare the recommendations for 5 test movies with different weightings, and a simple check: the share of recommendations sharing at least one genre with the chosen movie. Write your findings in README.md. Done when: README.md compares at least three weightings with examples.
- 06
Package and test it
~1.5hOrganize the code into a module (data loading, model building and recommendation) with the CLI on top. Write pytest tests on a tiny hand-made dataset: a movie is never recommended to itself, results are sorted by score, unknown titles give suggestions, and n is respected. Done when: pytest passes.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack