This project implements a movie recommendation system using Streamlit for the user interface and TMDb (The Movie Database) API for fetching movie posters. It leverages precomputed similarity data to recommend movies similar to the one selected by the user.
- Movie Search: Allows users to select a movie from a list.
- Recommendations: Provides top 10 movie recommendations based on the selected movie.
- Posters: Displays movie posters alongside recommendations for a better visual experience.
pandas
for data manipulationstreamlit
for creating the web app interfacepickle
for loading precomputed datatmdbv3api
for accessing movie posters from TMDb
-
Install Dependencies:
pip install pandas streamlit pickle5 tmdbv3api
-
API Key:
Replace
'bf49392cc5a7db79873193791c6c5701'
with your TMDb API key. You can obtain an API key by signing up at TMDb API. -
Data Files:
Ensure you have the following files in your project directory:
movies.pkl
: Pickle file containing the movie dataset.similarity.pkl
: Pickle file containing the precomputed similarity matrix.
-
Save the code in a file named
app.py
. -
Run the Streamlit app using:
streamlit run app.py
-
Open the provided local URL in your browser to use the app.
fetch_poster(movie_title)
: Retrieves the poster URL for a given movie title using TMDb API.recommend(movie)
: Provides movie recommendations based on the selected movie. It uses precomputed similarity data to find and rank similar movies.- Streamlit Interface:
- Selectbox: Allows users to choose a movie for recommendations.
- Recommendation Display: Shows top 10 recommended movies with their posters.
- Data Loading: If the data files (
movies.pkl
,similarity.pkl
) cannot be loaded, an error message will be displayed. - Column Check: The app checks for the presence of the 'orig_title' column in the dataset and displays an error if it's missing.
Feel free to fork this repository and submit pull requests. Contributions and suggestions are welcome!