Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฌ Movie Success Predictor

A sophisticated machine learning-powered web application that predicts whether a movie will be a hit or a flop. This interactive quiz game lets users test their intuition against a trained ML model while learning about the factors that contribute to a movie's success.

Movie Success Predictor Preview

Python React TypeScript License

๐Ÿ“š Table of Contents

๐ŸŒŸ Overview

The Movie Success Predictor combines data science with an engaging user interface to create an educational game about movie success prediction. Users can:

  • Guess whether a movie was a hit or flop based on its details
  • Compare their predictions with a machine learning model
  • Learn about the factors that influence movie success
  • Filter movies by genre, country, and rating
  • Track their prediction accuracy

โœจ Features

๐ŸŽฎ Interactive Quiz Interface

  • Beautiful, responsive movie cards with TMDB posters
  • Real-time feedback on user predictions
  • Visual effects for correct/incorrect guesses
  • Timer-based gameplay for added challenge
  • Score tracking and statistics

๐ŸŽฏ Filtering & Customization

  • Filter movies by:
    • Genre
    • Country of origin
    • MPAA rating (certification)
  • Adjustable game settings
  • Premium UI with animations and transitions

๐Ÿ“Š Machine Learning Integration

  • Real-time predictions using Logistic Regression
  • Model confidence scores
  • Comparison between user and model predictions
  • Educational insights into prediction factors

๐Ÿ— Technical Architecture

Frontend (React + TypeScript + Vite)

  • Modern React with TypeScript for type safety
  • Vite for fast development and building
  • Tailwind CSS for responsive styling
  • Custom hooks for state management
  • Component-based architecture

Backend (Python + Flask)

  • Flask REST API
  • CORS support for local development
  • Environment-based configuration
  • Scikit-learn for ML predictions
  • TMDB API integration for movie posters

Machine Learning Pipeline

  • Data collection via TMDB API
  • Preprocessing and feature engineering
  • Model training and evaluation
  • Real-time prediction serving

๐Ÿค– Machine Learning Model

Data Features

  • Budget
  • Runtime
  • Release Year
  • Vote Average
  • Vote Count
  • Certification (MPAA Rating)
  • Genre
  • Country

Model Details

  • Algorithm: Logistic Regression
  • Accuracy: 70.47%
  • Features: One-hot encoded categorical variables
  • Training Data: 375,377 movies

Success Definition

A movie is considered successful (Hit) if:

  • Revenue >= Budget ร— 2
  • Otherwise classified as a Flop

๐Ÿ“Š Data Collection & Processing

Data Collection (scrape-movies.py)

  • Uses TMDB API for movie data
  • Collects movies from 1873 to 2020
  • Features include:
    • Basic movie information
    • Financial data (budget/revenue)
    • Ratings and popularity
    • Production details

Preprocessing (preprocessing.py)

  1. Data Cleaning

    • Removes duplicates
    • Handles missing values
    • Filters invalid entries
  2. Feature Engineering

    • Creates success column
    • Extracts primary genre
    • Processes release dates
    • Standardizes country information

Model Training (classification.py)

  • Implements multiple algorithms:
    • Logistic Regression
    • KNN
    • Decision Trees
    • Random Forest
  • Cross-validation for model selection
  • Hyperparameter tuning
  • Performance visualization

๐Ÿš€ Installation & Setup

Prerequisites

  • Python 3.9+
  • Node.js 16+
  • TMDB API Key

Backend Setup

# Clone the repository
git clone https://github.com/prashantkoirala465/Movie-Success-Predictor.git
cd Movie-Success-Predictor

# Set up Python virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\\Scripts\\activate

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env
# Edit .env and add your TMDB_API_KEY

# Start the backend server
cd backend
python app.py

Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

๐Ÿ“ก API Reference

GET /api/quiz/next-movie

Retrieves a random movie for prediction.

Query Parameters:

  • genre: Filter by movie genre
  • country: Filter by production country
  • certification: Filter by MPAA rating

Response:

{
  "id": "string",
  "title": "string",
  "posterUrl": "string"
}

POST /api/quiz/submit-guess

Submit a prediction for a movie.

Request Body:

{
  "movieId": "string",
  "guess": "Hit" | "Flop"
}

Response:

{
  "movieId": "string",
  "userGuess": "string",
  "prediction": "string",
  "actualResult": "string",
  "isCorrect": boolean,
  "feedbackMessage": "string"
}

GET /api/quiz/filter-options

Get available filter options.

Response:

{
  "genres": ["string"],
  "countries": ["string"],
  "certifications": ["string"]
}

๐Ÿ“ Project Structure

Movie-Success-Predictor/
โ”œโ”€โ”€ backend/                   # Python Flask backend
โ”‚   โ”œโ”€โ”€ app.py                # Main Flask application
โ”‚   โ”œโ”€โ”€ train_model.py        # Model training script
โ”‚   โ”œโ”€โ”€ data/                 # Dataset storage
โ”‚   โ”‚   โ””โ”€โ”€ moviesDb.csv     # Processed movie dataset
โ”‚   โ””โ”€โ”€ models/              # Trained ML models
โ”‚       โ”œโ”€โ”€ logistic_regression_model.joblib
โ”‚       โ””โ”€โ”€ model_columns.joblib
โ”œโ”€โ”€ frontend/        # React frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/      # Reusable React components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MovieCard.tsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ QuizControls.tsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ services/       # API services
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/         # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ assets/        # Static assets
โ”‚   โ””โ”€โ”€ public/             # Public assets
โ”œโ”€โ”€ data-collection/         # Data collection scripts
โ”‚   โ”œโ”€โ”€ scrape-movies.py    # TMDB data scraper
โ”‚   โ””โ”€โ”€ preprocessing.py    # Data preprocessing
โ”œโ”€โ”€ ml/                     # Machine learning
โ”‚   โ””โ”€โ”€ classification.py   # Model training
โ”œโ”€โ”€ docs/                   # Documentation
โ”‚   โ””โ”€โ”€ preview.png        # Project preview
โ”œโ”€โ”€ .env.example           # Example environment variables
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”œโ”€โ”€ .gitignore            # Git ignore rules
โ””โ”€โ”€ README.md             # Project documentation

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add some AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

๐Ÿ‘ฅ Team

  • Prashant Koirala - Project Lead & Full Stack Developer
  • Aaska Koirala - Machine Learning Engineer
  • Aishmita Yonzan - UI/UX Designer

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

About

A sophisticated machine learning-powered web application that predicts whether a movie will be a hit or a flop. This interactive quiz game lets users test their intuition against a trained ML model while learning about the factors that contribute to a movie's success.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages