Skip to content

Peyman-CE/rec-system

Repository files navigation

Pick a Movie for Me 🎬

A multi-user movie recommendation web application with reinforcement learning capabilities. The system learns from each user's preferences over time to provide personalized movie suggestions.

📖 For complete documentation, see DOCUMENTATION.md

Features

  • 🎲 Random Movie Recommendations - Get personalized movie suggestions
  • 🤖 Reinforcement Learning - The system learns from your feedback to improve recommendations
  • 🎨 Beautiful UI - Modern, responsive design with TailwindCSS
  • 📊 Genre-Based Learning - Uses multi-armed bandit algorithm to learn your genre preferences

Tech Stack

  • Backend: Flask (Python)
  • Frontend: HTML + TailwindCSS (CDN) + JavaScript
  • Movie Data: TMDB (The Movie Database) API
  • RL Model: Multi-armed bandit with epsilon-greedy strategy
  • Storage: JSON file for RL feedback data

Setup Instructions

1. Activate Virtual Environment

# On Windows
venv\Scripts\activate

# On macOS/Linux
source venv/bin/activate

2. Install Dependencies

pip install -r requirements.txt

3. Get TMDB API Key

  1. Go to TMDB
  2. Create a free account
  3. Go to API Settings
  4. Request an API key (free)
  5. Copy your API key

4. Set Environment Variable

Windows (PowerShell):

$env:TMDB_API_KEY="your_api_key_here"

Windows (CMD):

set TMDB_API_KEY=your_api_key_here

macOS/Linux:

export TMDB_API_KEY="your_api_key_here"

Or create a .env file (not included in git):

TMDB_API_KEY=your_api_key_here

5. Run the Application

python app.py

The application will be available at http://localhost:5000

How It Works

Reinforcement Learning Model

The system uses a multi-armed bandit approach where:

  • Each genre is an "arm" that can be pulled
  • The system tracks:
    • Total recommendations per genre
    • Positive feedback (likes) per genre
  • Expected reward = positive_count / total_count

Recommendation Strategy

  1. Epsilon-Greedy Algorithm:

    • 15% of the time: Explore (random genre)
    • 85% of the time: Exploit (genre with highest expected reward)
  2. Feedback Loop:

    • When you click "I Like This" → reward = 1
    • When you click "I Don't Like This" → reward = 0
    • The system updates genre statistics and saves to feedback_store.json
  3. Over Time:

    • Genres you like get recommended more often
    • Genres you dislike get recommended less often
    • The system adapts to your preferences

Project Structure

recom sys/
├── app.py                 # Flask application and routes
├── rl_model.py           # Reinforcement learning model
├── tmdb_service.py       # TMDB API integration
├── requirements.txt      # Python dependencies
├── feedback_store.json   # RL data (created automatically)
├── templates/
│   ├── index.html        # Landing page
│   ├── movie.html        # Movie recommendation page
│   └── error.html        # Error page
└── README.md             # This file

API Routes

  • GET / - Landing page
  • GET /recommend - Get a movie recommendation
  • POST /feedback - Submit feedback (JSON: {"genre": "Action", "liked": true})
  • GET /stats - View RL model statistics (debug endpoint)

Example Usage

  1. Visit http://localhost:5000
  2. Click "Pick a Movie for Me"
  3. View the recommended movie
  4. Click "I Like This" or "I Don't Like This"
  5. Click "Pick Another Movie" to get a new recommendation
  6. The system learns from your feedback!

Troubleshooting

"TMDB_API_KEY environment variable not set"

  • Make sure you've set the environment variable before running the app
  • Check that your API key is valid

"No genres available from TMDB"

  • Check your internet connection
  • Verify your TMDB API key is correct

"Could not fetch a movie"

  • TMDB API might be temporarily unavailable
  • Try again in a few moments

Future Enhancements

  • User sessions to track individual preferences
  • More sophisticated RL algorithms (UCB1, Thompson Sampling)
  • Movie filtering by rating, year, etc.
  • Watchlist functionality
  • Multiple user support

License

This is a personal project for educational purposes.

Credits

About

recommendation system for films on imdb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors