Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Movie Recommendation System

Python Streamlit Scikit-Learn Pandas NumPy TMDb

A Machine Learning powered Content-Based Movie Recommendation System built using Streamlit, Scikit-Learn and TMDb API.


πŸ“Œ Overview

The Movie Recommendation System is an interactive Machine Learning web application that recommends movies similar to a user's selected movie using Content-Based Filtering.

The recommendation engine analyzes movie genres using TF-IDF Vectorization and computes similarity scores using Cosine Similarity to identify movies with similar content.

To provide a richer user experience, the application integrates the TMDb API to fetch:

  • 🎬 Movie Posters
  • ⭐ TMDb Ratings
  • πŸ“… Release Dates
  • πŸ“– Movie Overview
  • 🌍 Original Language
  • πŸ”₯ Popularity Score
  • πŸ—³ Vote Count

The application is developed using Streamlit, providing a modern, responsive, and interactive web interface.


πŸš€ Features

πŸ€– Machine Learning

  • Content-Based Recommendation System
  • TF-IDF Vectorization
  • Cosine Similarity
  • Top-N Similar Movie Recommendations

πŸŽ₯ Movie Information

  • Movie Posters
  • Movie Overview
  • Release Date
  • TMDb Rating
  • Original Language
  • Popularity
  • Vote Count
  • Average User Rating

🎨 User Interface

  • Modern Dark Theme
  • Interactive Streamlit Dashboard
  • Responsive Layout
  • Sidebar Statistics
  • Recommendation Cards
  • Similarity Progress Bar
  • Genre Badges
  • Movie Search
  • Professional UI Design

⚑ Performance

  • Cached TMDb API Calls
  • Session State Management
  • Error Handling
  • Missing Poster Fallback
  • Fast Recommendation Retrieval

πŸ“Š Dataset

This project uses the MovieLens Latest Small Dataset.

Dataset Count
Movies 9,742
Users 610
Ratings 100,836
Tags 3,683+

Dataset includes:

  • Movies
  • Ratings
  • Tags
  • TMDb Links

🧠 Machine Learning Workflow

Movie Dataset
      β”‚
      β–Ό
Data Preprocessing
      β”‚
      β–Ό
Genre Extraction
      β”‚
      β–Ό
TF-IDF Vectorization
      β”‚
      β–Ό
Cosine Similarity Matrix
      β”‚
      β–Ό
Top Similar Movies
      β”‚
      β–Ό
TMDb API
      β”‚
      β–Ό
Interactive Streamlit Dashboard

πŸ“– Recommendation Algorithm

The recommendation pipeline consists of the following steps:

  1. User selects a movie.
  2. Movie genres are converted into TF-IDF vectors.
  3. Cosine similarity is computed between movies.
  4. Top similar movies are selected.
  5. Movie metadata is fetched from TMDb.
  6. Recommendations are displayed with posters and ratings.

πŸ›  Tech Stack

Category Technology
Programming Language Python
Machine Learning Scikit-Learn
Data Processing Pandas, NumPy
Web Framework Streamlit
API TMDb API
Model Serialization Joblib
Visualization Matplotlib

πŸ“‚ Project Structure

Movie_Recommendation_System/

β”‚

β”œβ”€β”€ app/
β”‚   └── app.py

β”œβ”€β”€ dataset/
β”‚   β”œβ”€β”€ movies.csv
β”‚   β”œβ”€β”€ ratings.csv
β”‚   β”œβ”€β”€ links.csv
β”‚   └── tags.csv

β”œβ”€β”€ model/
β”‚   β”œβ”€β”€ cosine_similarity.pkl
β”‚   β”œβ”€β”€ movie_indices.pkl
β”‚   └── movies.pkl

β”œβ”€β”€ notebooks/
β”‚   └── movie_recommendation.ipynb

β”œβ”€β”€ output/
β”‚   β”œβ”€β”€ Home Page.png
β”‚   β”œβ”€β”€ Selected Movie.png
β”‚   β”œβ”€β”€ Recommendations.png
β”‚   β”œβ”€β”€ average_rating_distribution.png
β”‚   β”œβ”€β”€ genre_distribution.png
β”‚   β”œβ”€β”€ rating_distribution.png
β”‚   β”œβ”€β”€ ratings_per_movie.png
β”‚   β”œβ”€β”€ ratings_per_user.png
β”‚   β”œβ”€β”€ top_rated_movies.png
β”‚   └── top_users.png

β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── .gitignore

πŸ“· Application Screenshots

🏠 Home Page

Home Page


🎬 Selected Movie

Selected Movie


🍿 Movie Recommendations

Recommendations


πŸ“Š Exploratory Data Analysis

Average Rating Distribution

Average Rating


Genre Distribution

Genre Distribution


Rating Distribution

Rating Distribution


Ratings Per Movie

Ratings Per Movie


Ratings Per User

Ratings Per User


Top Rated Movies

Top Rated Movies


Top Users

Top Users


πŸ“ˆ Results

βœ” Successfully recommends similar movies.

βœ” Real-time movie posters using TMDb.

βœ” Displays ratings, release dates and overview.

βœ” Professional interactive dashboard.

βœ” Supports more than 9,700 movies.

βœ” Average response time below 2 seconds after caching.


πŸ’» Installation

Clone the repository

git clone https://github.com/YOUR_USERNAME/Movie_Recommendation_System.git

Navigate to project folder

cd Movie_Recommendation_System

Create virtual environment

python -m venv .venv

Activate virtual environment

Windows

.venv\Scripts\activate

Linux/macOS

source .venv/bin/activate

Install dependencies

pip install -r requirements.txt

πŸ”‘ TMDb API Configuration

Create a folder named:

.streamlit

Create a file:

secrets.toml

Add your TMDb credentials:

TMDB_API_KEY="YOUR_API_KEY"

TMDB_BEARER_TOKEN="YOUR_BEARER_TOKEN"

β–Ά Running the Application

streamlit run app/app.py

🐞 Troubleshooting

Posters not loading

  • Verify your TMDb API credentials.
  • Check your internet connection.
  • Ensure tmdbId exists for the selected movie.

Missing Model Files

Verify that the following files exist:

movies.pkl
movie_indices.pkl
cosine_similarity.pkl

Slow Loading

The first TMDb request may take longer.

Subsequent requests are cached automatically.


πŸš€ Future Improvements

  • Hybrid Recommendation System
  • Collaborative Filtering
  • Deep Learning Recommendation Model
  • Personalized Recommendations
  • User Authentication
  • Favorite Movies
  • Watchlist
  • Movie Trailer Integration
  • Actor & Director Information
  • Genre & Year Filters
  • Deploy on Streamlit Community Cloud

πŸ“š Learning Outcomes

Through this project, I gained practical experience in:

  • Machine Learning Recommendation Systems
  • TF-IDF Vectorization
  • Cosine Similarity
  • Content-Based Filtering
  • Data Preprocessing
  • API Integration
  • Streamlit Application Development
  • Session State Management
  • Model Serialization
  • Interactive Dashboard Design

πŸ‘¨β€πŸ’» Author

Harsh Vardhan Chaudhary

B.Tech Computer Science & Engineering
SRM Institute of Science and Technology


🌐 Connect With Me

LinkedIn

https://www.linkedin.com/in/connect-harsh-vardhan

GitHub

https://github.com/harshvardhan4096


⭐ Support

If you found this project useful, consider giving this repository a ⭐ on GitHub.

It motivates me to build and share more Machine Learning and AI projects.


πŸ“„ License

This project is licensed under the MIT License.

About

A Machine Learning based Content-Based Movie Recommendation System using TF-IDF, Cosine Similarity, Streamlit and TMDb API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages