MovieInsightML is an end‑to‑end machine learning project that predicts movie revenue (regression) and identifies a movie’s main genre (multi‑class classification) using a combination of text features (overview, title, tagline) and numeric features (budget, popularity, ratings, etc.).
All core models (linear/logistic regression, decision trees, random forests, KNN) are implemented from scratch using NumPy, and the final best models are exported to TensorFlow Lite (TFLite) for TinyML / edge deployment.
At the project root:
i210277_MovieInsightML.ipynb: Main Jupyter notebook containing the complete pipeline:- data loading and cleaning
- feature engineering (numeric + text)
- custom NumPy implementations of ML models
- evaluation, visualization, and TinyML export
MovieInsightML_Project_Report.md: Written report summarizing the full project (objectives, methods, results, discussion, future work).i210277_MovieInsightMLReport.pdf: PDF version of the project report / submission.Machine_Learning_Project_FA2025.pdf: Original course project specification / assignment handout.train.csv: Training dataset used for model development.test.csv: Held‑out dataset used for generalization checks and deployment.numpy_model_weights.pkl: Serialized NumPy weights for trained models.movie_revenue_regression.tflite: Exported TFLite model for the revenue regression task.movie_genre_classification.tflite: Exported TFLite model for the genre classification task.classification_impulse.png,regression_impulse.png: Edge/TinyML impulse design screenshots (model blocks, input features, etc.).tf_classification_model/: SavedModel directory for the TensorFlow classification model (assets, variables,saved_model.pb).tf_regression_model/: SavedModel directory for the TensorFlow regression model (assets, variables,saved_model.pb).
-
Regression task: Predict the box office revenue of a movie using:
- numeric features:
budget,popularity,runtime,vote_average,vote_count, etc. - engineered text‑based statistics from the
overviewfield (word count, character count, average word length, sentiment score). - TF‑IDF features computed from the
overviewtext.
- numeric features:
-
Classification task: Predict the main movie genre (16 classes: top 15 genres +
Other) using:- the same numeric and engineered text features as above
- TF‑IDF features from the
overviewtext - genre labels extracted and cleaned from the
genrescolumn.
The project demonstrates how to integrate NLP features + numeric features in a single pipeline, perform model comparison, and deploy the best models to TinyML‑friendly formats.
- Source: Large movie metadata dump (train/test splits already provided).
- Files:
train.csv– 577,853 rows and 20 columns (reduced to ~538k after deduplication).test.csv– 144,464 rows and 20 columns.
- Key columns:
- Textual:
overview,title,tagline,genres. - Numeric:
budget,revenue,popularity,runtime,vote_average,vote_count. - Categorical/metadata:
original_language,status,release_date,production_companies,credits,keywords,recommendations,id.
- Textual:
- Targets:
- Regression:
revenue(continuous, skewed, many zeros). - Classification:
main_genre(derived fromgenres, mapped to 16 classes).
- Regression:
Data issues handled in the notebook:
- missing values in text and numeric fields
- duplicate rows removed using
id - class imbalance across genres
- extreme outliers in revenue and budget.
The full implementation lives in i210277_MovieInsightML.ipynb. At a high level:
-
Data cleaning
- Fill missing overview text with empty strings.
- Impute numeric features (
budget,popularity,runtime,vote_average,vote_count) with medians. - Remove duplicate movies based on
id.
-
Feature engineering
- Overview text statistics:
- word count, character count, average word length
- simple rule‑based sentiment score using positive/negative word lists.
- Genre extraction:
- parse
genresstrings of different formats - take the first genre as
main_genre - keep top 15 genres, map all others to
Other→ 16 total classes.
- parse
- Normalization:
- Z‑score normalization for numeric and engineered features.
- TF‑IDF:
- custom NumPy implementation
- vocabulary built on train set
- originally 1,000 terms, reduced to 100 dimensions for memory efficiency.
- Final feature vector:
- 8 normalized numeric/engineered features
- 100 TF‑IDF features
- total ≈ 108 dimensions.
- Overview text statistics:
-
Subsampling for efficiency
- ~50,000 samples used for each of regression and classification to keep RAM usage in MBs.
All core algorithms are implemented manually using NumPy only:
-
Regression
- Linear Regression (mini‑batch gradient descent, optional L2 regularization).
- Decision Tree Regressor (MSE‑based splits, depth/leaf constraints).
- Random Forest Regressor (bagging + feature subsampling, aggregation by mean).
-
Classification
- Logistic Regression (One‑vs‑Rest, gradient descent).
- K‑Nearest Neighbors (Euclidean distance, (k = 5)).
- Decision Tree Classifier (Gini impurity).
- Random Forest Classifier (majority vote across trees).
Additional analysis:
- K‑Means and hierarchical clustering on TF‑IDF features.
- Isolation Forest‑style outlier detection for revenue anomalies.
- PCA and plotting for cluster visualization.
Evaluation uses:
- Regression: MAE, RMSE, R².
- Classification: accuracy, macro precision/recall/F1, confusion matrices.
- Cross‑validation: 3‑fold CV for both tasks.
From MovieInsightML_Project_Report.md:
-
Regression
- Best overall model: Random Forest Regressor with R² ≈ 0.49 on subsampled data.
- Decision Tree achieves competitive MAE; Linear Regression is a strong baseline.
- Budget and popularity emerge as key predictors of revenue.
-
Classification
- 16‑class genre prediction is difficult due to imbalance and genre ambiguity.
- One‑vs‑Rest Logistic Regression reaches only low accuracy; tree‑based models and ensembles perform better but still leave room for improvement.
-
TinyML / TFLite
- TFLite models are >90% smaller than their SavedModel counterparts:
- Regression: ~0.0231 MB → ~0.0015 MB.
- Classification: ~0.0361 MB → ~0.0032 MB.
- Inference is fast with RAM usage < 1 MB and flash < ~5 KB per model, making them suitable for edge devices and platforms like Edge Impulse.
- TFLite models are >90% smaller than their SavedModel counterparts:
For full tables, figures, and discussion, see MovieInsightML_Project_Report.md and the notebook.
- Python: 3.9+ recommended
- Suggested packages (install via
piporconda):numpypandasmatplotlibseabornscikit-learn(for metrics and utilities)jupyterorjupyterlabtensorflow(only needed if you want to re‑export or modify the SavedModel/TFLite models)
Example using pip:
pip install numpy pandas matplotlib seaborn scikit-learn jupyter tensorflow- Clone or copy the project folder to your machine.
- Ensure
train.csvandtest.csvare present in the project root (as provided). - Launch Jupyter:
jupyter notebook
- Open
i210277_MovieInsightML.ipynb. - Run the cells in order (restart and run all for a clean execution):
- Data preparation and EDA.
- Feature engineering and TF‑IDF computation.
- Model training and cross‑validation.
- Clustering and outlier detection.
- TensorFlow model export and TFLite conversion (if rerunning).
You can load and run inference with the provided .tflite models directly, without retraining.
High‑level steps (Python, using TensorFlow Lite Interpreter):
import numpy as np
import tensorflow as tf
# Load TFLite model
interpreter = tf.lite.Interpreter(model_path="movie_revenue_regression.tflite")
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# x should be a preprocessed feature vector matching the training pipeline
x = np.random.rand(1, input_details[0]["shape"][1]).astype(np.float32)
interpreter.set_tensor(input_details[0]["index"], x)
interpreter.invoke()
prediction = interpreter.get_tensor(output_details[0]["index"])
print("Predicted revenue:", prediction)For genre classification, load movie_genre_classification.tflite instead and map the output index to the corresponding genre label (same mapping used in the notebook).
Important: Inputs must go through the same preprocessing pipeline used during training (normalization and TF‑IDF feature construction), which is fully documented in the notebook and report.
To reproduce the results in the report:
- Open
i210277_MovieInsightML.ipynb. - Follow the notebook sections in order:
- Data loading and cleaning.
- Feature engineering and TF‑IDF.
- Model training (regression and classification).
- Cross‑validation and metrics.
- Clustering and outlier detection.
- TensorFlow → TFLite export.
- Compare the printed metrics and plots to those summarized in
MovieInsightML_Project_Report.md.
As outlined in the report, potential extensions include:
- richer text representations (embeddings, transformers)
- better handling of class imbalance (class weights, resampling)
- more advanced ensembles (gradient boosting, XGBoost)
- deeper hyperparameter tuning and model selection
- integration into a real‑time recommendation or analytics system.
- Name: Muhammad Talha Syed
- Project: MovieInsightML – Revenue Forecasting & Genre Classification Using Text and Numeric Features