This repository contains two different movie recommendation systems:
- Mood-Based Movie Recommendation System: Recommends movies based on user-selected mood without requiring a specific title input.
- Title-Based Movie Recommendation System: Recommends movies based on user-input movie title and personalized mood selection, leveraging content-based and collaborative filtering methods.
Each recommendation system uses the MovieLens dataset to analyze movie genres, ratings, and user mood, generating movie suggestions tailored to user preferences.
- General Information
- Requirements
- Dataset
- 1. Mood-Based Movie Recommendation System
- 2. Title-Based Movie Recommendation System
- Project Structure
- Acknowledgments
This project demonstrates two distinct approaches to movie recommendations:
- Mood-based approach: Generates recommendations based on predefined genre mappings for moods like "happy" or "nostalgic."
- Title-based approach: Combines collaborative and content-based filtering to suggest similar movies based on an input movie title and user mood.
Both systems are implemented in Python and feature a simple user interface using Streamlit.
The project requires the following libraries:
- Python 3.7+
- pandas
- numpy
- scikit-learn
- nltk
- streamlit
Install the required packages:
pip install pandas numpy scikit-learn nltk streamlit
The MovieLens dataset is used, specifically ml-1m
(MovieLens 1M) in .dat
format, which includes movie titles, genres, and user ratings.
Due to encoding issues, the dataset is loaded using ISO-8859-1
encoding, with the following files:
movies.dat
: Movie IDs, titles, and genres.ratings.dat
: User IDs, movie IDs, ratings, and timestamps.
The Mood-Based Movie Recommendation System recommends movies based on a selected mood. Moods such as "happy," "sad," "angry," and "nostalgic" are mapped to genres like "Comedy," "Action," and "Drama." Users select their mood, and the system generates a list of popular movies fitting that mood.
Mood | Genres |
---|---|
Happy | Comedy, Romance |
Sad | Drama, Thriller |
Angry | Action, Thriller |
Fearful | Horror, Thriller |
Surprised | Thriller, Mystery |
Adventurous | Action, Adventure |
Nostalgic | Animation, Family |
-
Run the code in a terminal or editor (e.g., Visual Studio Code):
streamlit run mood_based_recommendation.py
-
Select a mood from the dropdown and click "Get Recommendations" to see a list of recommended movies.
The Title-Based Movie Recommendation System combines content-based filtering (by movie genres) with collaborative filtering (user ratings) to recommend movies based on a selected movie title and mood. The system suggests movies similar to the input title and fitting the selected mood.
- Content-Based Filtering: Uses movie genres to find movies similar to the input title.
- Collaborative Filtering: Leverages user ratings with
NearestNeighbors
to find similar movies based on ratings. - Mood-Based Genre Filtering: Filters recommendations by user-selected mood.
-
Run the code in a terminal or editor (e.g., Visual Studio Code):
streamlit run title_based_recommendation.py
-
Enter a movie title and select a mood, then click "Get Recommendations" to generate personalized suggestions.
├── ml-1m/ # Dataset folder
│ ├── movies.dat # Movies file with movie IDs, titles, genres
│ └── ratings.dat # Ratings file with user IDs, movie IDs, ratings, timestamps
├── mood_based_recommendation.py # Code for mood-based recommendation system
├── title_based_recommendation.py # Code for title-based recommendation system
└── README.md # Project README file