How bharath-allala/movie-recommendation works
Purpose and Entry Point
This repository is a content-based movie recommendation application. The runtime entry point is the Streamlit UI in app.py, launched with streamlit run app.py. It serves recommendations from precomputed local artifacts rather than building models during user requests.
Offline Artifact-Build Stage
build_artifacts.py is the offline preprocessing/training boundary. It prepares the cleaned movie catalog, vectorization model, and sparse feature matrix consumed by the application:
• build_artifacts.py
• movies_processed.pkl
• vectorizer.pkl
This separates expensive dataset cleaning and vector creation from interactive serving.
Movie Catalog and Feature Representation
The processed catalog in movies_processed.pkl is the central metadata store used for search, display, and ranking. Movie content is represented from overview, genres, keywords, leading cast, and director; genres and directors receive higher weighting before Bag-of-Words generation.
The fitted Scikit-learn vectorizer is persisted in vectorizer.pkl, allowing feature semantics to remain consistent with the stored vectors.
Similarity Retrieval Engine
tag_vectors.npz stores the sparse movie-feature matrix. At request time, the app finds the selected movie’s vector and performs cosine-similarity retrieval against this matrix:
• app.py
• tag_vectors.npz
• vectorizer.pkl
Using an .npz sparse artifact avoids recomputing vectors and avoids requiring the source TMDB dataset in production.
Ranking Boundary
Similarity is the candidate-generation signal; the application then applies hybrid re-ranking that incorporates weighted movie ratings. This makes content resemblance the primary retrieval mechanism while allowing stronger-rated movies to rank above otherwise comparable candidates:
• app.py
• movies_processed.pkl
• tag_vectors.npz
User Interaction and Serving Runtime
app.py owns the Streamlit interaction flow: movie search/selection, recommendation invocation, and result rendering. The deployed system is a Python/Streamlit process with local filesystem artifacts; no database, API integration, or separate backend service is represented in the repository.
Material Dependencies and Deployment Model
The runtime depends on Python with Streamlit, Pandas, NumPy, Scikit-learn, and SciPy, declared in requirements.txt. The application is designed for Streamlit hosting and has a published Streamlit deployment link. Its only persistent data/model infrastructure is versioned serialized local files:
• requirements.txt
• movies_processed.pkl
• tag_vectors.npz
Main entry points: build_artifacts.py Artifact builder · app.py Movie search and selection · movies_processed.pkl Processed movie catalog · vectorizer.pkl Fitted vectorizer
Components 13
Offline artifact build
Precomputes the catalog and feature artifacts.
- Artifact builder · Cleans data and persists serving artifacts.
build_artifacts.py - Weighted content features · Weights genres and directors above other movie metadata.
Versioned local artifacts
Files shared between build and serving.
- Processed movie catalog · Metadata store for search, display, ratings, and ranking.
movies_processed.pkl - Fitted vectorizer · Preserves feature semantics for stored vectors.
vectorizer.pkl - Sparse tag vectors · Precomputed movie-content vectors.
tag_vectors.npz
Streamlit serving runtime
Interactive recommendation process.
- Python dependencies · Declares Streamlit, Pandas, NumPy, Scikit-learn, and SciPy.
requirements.txt - Streamlit app · Launched with streamlit run app.py.
app.py - Movie search and selection
app.py - Cosine similarity retrieval · Compares the selected movie vector with the sparse matrix.
app.py - Hybrid re-ranking · Combines content similarity with weighted movie ratings.
app.py - Recommendation rendering
app.py
Other components
- Movie explorer
- Streamlit hosting · Runs the Python process with local artifacts.
Connections 18
- Artifact builder → Weighted content features: builds
- Artifact builder → Processed movie catalog: writes
- Weighted content features → Fitted vectorizer: fits and persists
- Weighted content features → Sparse tag vectors: produces
- Artifact builder → Fitted vectorizer: writes
- Artifact builder → Sparse tag vectors: writes
- Python dependencies → Streamlit app: provides runtime packages
- Streamlit hosting → Streamlit app: runs
- Movie explorer → Movie search and selection: searches and selects
- Streamlit app → Movie search and selection: owns interaction
- Movie search and selection → Processed movie catalog: searches metadata
- Movie search and selection → Cosine similarity retrieval: selected movie
- Fitted vectorizer → Cosine similarity retrieval: feature semantics
- Sparse tag vectors → Cosine similarity retrieval: sparse matrix
- Cosine similarity retrieval → Hybrid re-ranking: similarity candidates
- Processed movie catalog → Hybrid re-ranking: ratings and metadata
- Hybrid re-ranking → Recommendation rendering: ranked recommendations
- Recommendation rendering → Movie explorer: displays results