A content-based Movie Recommender System built using Python. This project leverages natural language processing and machine learning techniques to recommend movies similar to a selected movie. The core functionalities are implemented in Preprocessing.py
, while app.py
handles the deployment using Streamlit, providing an interactive web interface.
mre-demo-video.mp4
- Features
- Demo
- Installation
- Usage
- Project Structure
- Requirements
- API Setup
- Contributing
- License
- Acknowledgements
- Content-Based Recommendations: Recommends movies based on content similarity using cosine similarity.
- Interactive Web Interface: Users can select a movie and receive top 5 similar movie recommendations with posters.
- Movie Posters: Fetches and displays movie posters using The Movie Database (TMDB) API.
- Deployment Ready: Easily deployable using Streamlit for web applications.
-
Clone the Repository
git clone https://github.com/nnilayy/Movie-Recommender-Engine.git cd Movie-Recommender-Engine
-
Create a Virtual Environment (Optional but Recommended)
uv venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Requirements
pip install -r requirements.txt
-
Set Up TMDB API Key
-
Obtain an API key from TMDB.
-
Option 1 (Development): Create a
.env
file in the root directory and add:TMDB_API_KEY=your_api_key_here
Ensure that
python-dotenv
is installed. -
Option 2 (Production/Streamlit Sharing): Add the API key to Streamlit secrets.
# In .streamlit/secrets.toml TMDB_API_KEY = "your_api_key_here"
-
-
Data Preprocessing
Run the
Preprocessing.py
script to process the dataset and generate necessary pickle files for the recommendation engine.python Preprocessing.py
This script will generate
movie_dict.pkl
andsimilarity.pkl
inside themodel_files
directory. -
Run the App
streamlit run app.py
-
Interact with the App
- Access the app at
http://localhost:8501
in your web browser. - Select a movie from the dropdown menu.
- View the top 5 recommended movies along with their posters.
- Access the app at
Movie-Recommender-Engine/
── app.py
── Preprocessing.py
── requirements.txt
── README.md
── model_files/
│ ├── movie_dict.pkl
│ ── similarity.pkl
── .env
- app.py: The Streamlit app handling user interactions and displaying recommendations.
- Preprocessing.py: Script for preprocessing data and building the recommendation model.
- requirements.txt: Lists all Python dependencies.
- model_files/: Directory containing serialized model files.
- .env: File containing environment variables (not included in the repository).
To fetch movie posters, the app uses TMDB API. Follow these steps to set up:
-
Register on TMDB
- Sign up at TMDB to create an account.
- Navigate to API section and apply for an API key.
-
Add API Key to the Project
- As mentioned in the Installation section, add your API key using one of the options.
-
Modify
app.py
(If Necessary)-
Ensure that
tmdb_api_key
is correctly set inapp.py
.# If using .env file from dotenv import load_dotenv load_dotenv() tmdb_api_key = os.getenv('TMDB_API_KEY')
# If using Streamlit secrets tmdb_api_key = st.secrets["TMDB_API_KEY"]
-
Contributions are welcome! Please open an issue or submit a pull request for any improvements.
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Changes
git commit -m "Add your message"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
This project is licensed under the MIT License.
- Datasets: The dataset used for this project is sourced from TMDB 5000 Movie Dataset.
- Inspiration: This project is inspired by the Movie Recommendation systems commonly seen on platforms like Netflix and Amazon Prime.
- Libraries and Tools:
- Author: Nilay Kumar Bhatnagar
- Email: [email protected]