This project is a content-based movie recommendation system that utilizes Natural Language Processing to suggest films based on the semantic meaning of user descriptions. Unlike keyword-based search engines, this system employs deep learning embeddings to understand the context and themes provided in a text prompt.
The core of the application relies on converting movie metadata into high-dimensional vectors. By calculating the Cosine Similarity between a user's input and a pre-processed database of films, the engine identifies movies with the highest thematic relevance. The system is designed with a Flask backend and a modern, responsive web interface.
The project utilizes the TMDB 10,000 Movies Dataset (Updated 2022). This dataset provides comprehensive metadata for approximately 10,000 films, including the specific fields required for both the recommendation logic and the user interface.
The recommendation logic is divided into two primary phases:
The data pipeline, documented in movies_embeddings_creation.ipynb, processes the metadata through the following steps:
- Model Selection: Uses the
all-mpnet-base-v2model from the Sentence Transformers library to generate embeddings. - Feature Extraction: Cleans and treats metadata columns for titles, overviews, and genres.
- Granular Embedding Generation: Creates separate vectors for the title, overview, and genres of each film to allow for specific weighting.
The engine utilizes a weighted linear combination to determine the final similarity score:
-
Weight Distribution: The system assigns
$0.5$ to the overview,$0.35$ to the title, and$0.15$ to the genres. -
Similarity Calculation: Employs Scikit-Learn’s
cosine_similarityto compare the input embedding against the stored vectors. - Filtering: Automatically excludes entries with empty overviews or missing genre tags to ensure recommendation quality.
- Backend: Python, Flask
- Data Science: Pandas, NumPy, Scikit-Learn, Sentence-Transformers, PyTorch
- Frontend: HTML5, CSS3 (Glassmorphism), Vanilla JavaScript
- Python 3.8 or higher
- Pip package manager
- Clone the repository:
git clone https://github.com/Cairo-Henrique/Movie-Recommender.git cd Movie-Recommender - Install the required dependencies
- Generate the embedding database:
- Open
movies_embeddings_creation.ipynband execute the cells to generate the.pklfile containing the vectors.
- Open
- Launch the application:
python app.py
app.py: The main Flask application handling routing and recommendation requests.app_functions.py: The code for themoviesdataset and the main functions used inapp.py.movies_embeddings_creation.ipynb: The research and development notebook used for data cleaning and embedding generation.static/: Contains the CSS for the glassmorphism interface and JavaScript for interactive UI elements.templates/: HTML templates for the web interface.movies.csv: original IMDB movies dataset.dataset_treatment.py: data cleaning of the original movies dataset; output:movies_fixed.py.movies_fixed.csv: The treated dataset containing movie metadata.
