Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Movie Success Predictor

Python PyTorch License Status

Predict whether your movie will be a HIT or FLOP using Deep Learning!

An AI-powered movie success prediction system that uses BERT transformers and multi-task deep learning to predict:

  • Hit/Flop Classification (success probability)
  • Box Office Revenue (predicted earnings)
  • Profit/Loss (financial outcome including negative profits)
  • ROI (return on investment)

Features

  • State-of-the-art NLP: Uses DistilBERT (66M parameters) for understanding movie plots
  • Multi-task Learning: Predicts 3 outputs simultaneously for better accuracy
  • Handles Losses: Uses signed log transformation to predict negative profits
  • No Data Leakage: Classification based on ratings, not revenue
  • Production Ready: Includes Gradio web interface for deployment
  • Comprehensive Evaluation: Full metrics, visualizations, and diagnostics

Model Performance

Metric Score
Classification Accuracy ~75-80%
Revenue R² Score ~0.40-0.60
Profit R² Score ~0.40-0.60
ROC-AUC ~0.68

Note: Movie success prediction is inherently uncertain due to factors like marketing, timing, and audience reception that aren't in the data.


Architecture

┌─────────────────────────────────────────────────────────────┐
│                         INPUT                               │
│  Text: "Movie plot... Directed by X"                       │
│  Numeric: [Budget, Popularity, Runtime, Genres, Votes]     │
└────────────────────┬────────────────────────────────────────┘
                     │
         ┌───────────┴───────────┐
         │                       │
    ┌────▼─────┐         ┌──────▼──────┐
    │   BERT   │         │   Dense     │
    │  (768D)  │         │  Layers     │
    └────┬─────┘         └──────┬──────┘
         │                      │
    ┌────▼─────┐         ┌──────▼──────┐
    │ Dense256 │         │  Dense64    │
    │ Dense128 │         │  Dense32    │
    └────┬─────┘         └──────┬──────┘
         │                      │
         └───────────┬──────────┘
                     │
              ┌──────▼──────┐
              │  Shared     │
              │  Dense128   │
              │  Dense64    │
              └──────┬──────┘
                     │
         ┌───────────┼───────────┐
         │           │           │
    ┌────▼────┐ ┌───▼────┐ ┌───▼────┐
    │ Hit/Flop│ │Revenue │ │ Profit │
    │(Sigmoid)│ │(Linear)│ │(Linear)│
    └─────────┘ └────────┘ └────────┘

Key Components:

  • Text Encoder: DistilBERT (distilbert-base-uncased)
  • Numeric Branch: StandardScaler + Dense layers
  • Multi-task Head: 3 output branches with different loss functions
  • Total Parameters: ~67M

Quick Start

Prerequisites

Python 3.8+
CUDA-capable GPU (optional, for faster training)

Installation

# Clone the repository
git clone https://github.com/yourusername/movie-success-predictor.git
cd movie-success-predictor

# Install dependencies
pip install -r requirements.txt

Download Dataset

Download the TMDb 5000 Movie Dataset:

Place them in the project root directory.

Training

# Run training script
python train.py

# Or use the Jupyter notebook
jupyter notebook Movie_Success_Predictor.ipynb

Quick Prediction

from predict import predict_new_movie

result = predict_new_movie(
    model=model,
    tokenizer=tokenizer,
    title="Avengers: Endgame",
    overview="The Avengers assemble for a final battle against Thanos",
    budget=356_000_000,
    popularity=150,
    runtime=181,
    genre_count=3,
    vote_count=15000
)

print(f"Classification: {result['classification']}")
print(f"Predicted Revenue: ${result['predicted_revenue']:,.0f}")
print(f"Predicted Profit: ${result['predicted_profit']:,.0f}")

Web Interface

Launch the Gradio web app:

python app.py

Or deploy instantly in Google Colab:

!pip install gradio
import gradio as gr

# ... (load model) ...

demo = gr.Interface(...)
demo.launch(share=True)  # Creates public URL!

Demo Features:

  • Mobile-friendly
  • Real-time predictions
  • Detailed financial forecasts
  • Investment recommendations

Project Structure

movie-success-predictor/
│
├── data/
│   ├── tmdb_5000_movies.csv          # Movie dataset
│   └── tmdb_5000_credits.csv         # Credits dataset
│
├── models/
│   ├── movie_model_best.pth          # Trained model weights
│   ├── scalers.pkl                   # Feature scalers
│   └── tokenizer/                    # BERT tokenizer
│
├── notebooks/
│   └── Movie_Success_Predictor.ipynb # Training notebook
│
├── src/
│   ├── train.py                      # Training script
│   ├── evaluate.py                   # Evaluation script
│   ├── predict.py                    # Prediction functions
│   └── model.py                      # Model architecture
│
├── app.py                            # Gradio web interface
├── requirements.txt                  # Dependencies
├── README.md                         # This file
└── LICENSE                           # MIT License

**Feature Engineering:**
```python
# Label: Based on ratings (no data leakage)
label = 1 if vote_average >= 7.0 else 0

# Signed log for profit (handles negative values)
def signed_log(x):
    return np.sign(x) * np.log1p(np.abs(x))

# Log transform for revenue
log_revenue = np.log1p(revenue)

Scaling:

  • Numeric features: StandardScaler (zero mean, unit variance)
  • Revenue target: MinMaxScaler on log-transformed values
  • Profit target: MinMaxScaler on signed-log values

Loss Function

loss = (10.0 * BCE_loss_classification + 
        1.0 * MSE_loss_revenue + 
        1.0 * MSE_loss_profit)

Why weighted?

  • Classification loss is weighted higher (10x) to ensure the model doesn't ignore it
  • Revenue and profit use MSE for continuous prediction

Optimization

  • Optimizer: AdamW (learning_rate=2e-5, weight_decay=0.01)
  • Scheduler: Linear warmup (10% of steps) + decay
  • Early Stopping: Patience=5 epochs
  • Gradient Clipping: max_norm=1.0

Evaluation

Classification Metrics

              precision    recall  f1-score   support

        Flop       0.76      0.95      0.84       492
         Hit       0.65      0.28      0.39       154

    accuracy                           0.75       646

Regression Performance

Revenue Prediction:

  • MAE: ~$50-80M
  • RMSE: ~$100-150M
  • R²: ~0.40-0.60

Profit Prediction:

  • MAE: ~$40-70M
  • RMSE: ~$90-140M
  • R²: ~0.40-0.60

Visualizations

Run evaluation to generate:

  • Confusion matrix
  • ROC curve
  • Revenue/profit scatter plots
  • Residual plots
  • Error distributions
python evaluate.py

Use Cases

  1. Studio Executives: Evaluate script potential before greenlight
  2. Producers: Estimate budget and revenue expectations
  3. Investors: Assess financial risk and ROI
  4. Film Students: Learn about factors affecting movie success
  5. Data Scientists: Study multi-task deep learning architecture

🛠️ Customization

Add New Features

# In train.py, add to num_cols:
num_cols = ['budget', 'popularity', 'runtime', 'genre_count', 
            'vote_count', 'release_month', 'sequel_flag']  # Add these

Change Classification Threshold

# Default: 0.5
optimal_threshold = 0.4  # Lower threshold for more HIT predictions
label = 1 if probability >= optimal_threshold else 0

Adjust Loss Weights

# Increase classification importance
LOSS_WEIGHTS = {
    'class': 15.0,    # Higher = more focus on hit/flop
    'revenue': 1.0,
    'profit': 1.0
}

Future Improvements

  • Add temporal features (release date, seasonality)
  • Include marketing budget and social media metrics
  • Implement ensemble methods (combine with XGBoost)
  • Fine-tune BERT layers instead of freezing
  • Add genre-specific models
  • Predict opening weekend separately
  • Include international box office
  • Add interpretability (SHAP values, attention visualization)

Known Issues

Issue 1: Always Predicts FLOP

Cause: Class imbalance (76% flops)
Solution:

# Use Focal Loss or adjust threshold
optimal_threshold = 0.3  # Instead of 0.5

Issue 2: Profit > Revenue

Cause: Independent prediction of profit and revenue
Solution:

# Calculate profit from revenue
pred_profit = pred_revenue - budget

Issue 3: Quadrillion Predictions

Cause: Double exponential or wrong scaler
Solution: Check scalers are fitted on log-transformed values

scaler_revenue.fit(df['log_revenue'])  # NOT df['revenue']

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

Citation

If you use this project in your research, please cite:

@misc{movie_success_predictor,
  author = Subhadeep Das,
  title = {Movie Success Predictor: Multi-task Deep Learning for Box Office Prediction},
  year = {2025},
  publisher = {GitHub},
  url = 
}

Acknowledgments


Contact

Subhadeep Das - @subhadeepd18@gmail.com

Screenshots

Training Progress

Training

Evaluation Dashboard

Dashboard

Web Interface

Web UI

Prediction Example

 PREDICTION FOR: 'Avatar: The Way of Water'
================================================

 Classification: Hit 
   Probability: 92.3%
   Confidence: Very Strong

 Financial Forecast:
   Budget:          $350,000,000
   Predicted Revenue: $2,304,567,890
   Predicted Profit:  $1,954,567,890

 Performance Metrics:
   ROI:            558.4%
   Profit Margin:   84.8%
   Success Ratio:    6.58x

 Recommendation:
    STRONG BUY - High success probability with excellent returns

About

Movie Prediction model using DistilBERT

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages