A hybrid movie recommendation system that combines Generalized Matrix Factorization (GMF) and Multi-Layer Perceptron (MLP) to provide personalized movie recommendations. The system is deployed using Render and is available at movierecommendation-system.onrender.com.
- Overview
- Features
- File Structure
- Setup
- Usage
- Deployment
- Evaluation
- Contributing
- License
- Acknowledgments
- Contact
This project is a movie recommendation system built using a hybrid model that combines GMF and MLP. It uses the MovieLens dataset to train the model and provides recommendations based on user input. The system is deployed as a web service using Render.
- Hybrid Model: Combines GMF and MLP for accurate recommendations.
- User Input: Users can input recently watched movies and their ratings.
- Personalized Recommendations: Provides top 10 movie recommendations based on user preferences.
- Deployment: Hosted on Render for easy access.
MovieRecommendation_System/
│
├── dataset/ # Directory containing the MovieLens 100k dataset
│ └── movielens-32m/ # Subdirectory for the specific dataset
│ ├── link.csv # CSV file containing movie links
│ ├── movies.csv # CSV file containing movie details (title, genres, etc.)
│ ├── ratings.csv # CSV file containing user ratings for movies
│ ├── tags.csv # CSV file containing user-generated tags for movies
│ ├── README.txt # Documentation for the dataset
│
│ └── movielens-100k/ # Subdirectory for the specific dataset
│ ├── link.csv # CSV file containing movie links
│ ├── movies.csv # CSV file containing movie details (title, genres, etc.)
│ ├── ratings.csv # CSV file containing user ratings for movies
│ ├── tags.csv # CSV file containing user-generated tags for movies
│ ├── README.txt # Documentation for the dataset
│
├── preprocess.py # Script for preprocessing the dataset
│
├── train.py # Script for training the recommendation model
│
├── model/ # Directory containing the trained model and related files
│ └── movielens-32m/ # Subdirectory for the specific dataset's model
│ ├── best_model.keras # Trained model saved in Keras format
│ ├── training_history.json # JSON file containing the training history
│ ├── model_architecture.png # Image file showing the model architecture
│ ├── training_history_plot.png # Plot of training and validation loss over epochs
│ └── predictions_vs_actual.png # Plot comparing predicted vs actual ratings
│
│ └── movielens-100k/ # Subdirectory for the specific dataset's model
│ ├── best_model.keras # Trained model saved in Keras format
│ ├── training_history.json # JSON file containing the training history
│ ├── model_architecture.png # Image file showing the model architecture
│ ├── training_history_plot.png # Plot of training and validation loss over epochs
│ └── predictions_vs_actual.png # Plot comparing predicted vs actual ratings
│
├── evaluate.py # Script for evaluating the trained model
│
├── generate_recommendations.py # Script for generating movie recommendations
│
├── app.py # Flask server script for hosting the recommendation system
│
├── static/ # Directory for static files (CSS, JS)
│ └── styles.css # CSS file for styling the frontend
│
├── templates/ # Directory for HTML templates
│ └── index.html # HTML template for the frontend
│
└── .env # Environment variables file for configuration
- Python 3.8 or higher
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/SoudeepGhoshal/MovieRecommendation_System.git cd MovieRecommendation_System -
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.envfile in the root directory. - Add the following variables:
DATASET = movielens-100k RATINGS_PATH = dataset/${DATASET}/ratings.csv MOVIES_PATH = dataset/${DATASET}/movies.csv PREPROCESSED_DATA_PATH = dataset/${DATASET}/preprocessed_data.pkl MODEL_PATH = model/${DATASET}/best_model.keras MODEL_ARCHITECTURE_PATH = model/${DATASET}/model_architecture.png TRAINING_HISTORY_PATH = model/${DATASET}/training_history.json PLOT_TRAINING_HISTORY_PATH = model/${DATASET}/training_history_plot.png PREDICTIONS_VS_ACTUAL_PATH = model/${DATASET}/predictions_vs_actual.png.png INDEX_PATH = 'index.html'
- Create a
-
Download the MovieLens-32M dataset and place it in the
dataset/movielens-32m/directory. [You may use any other version of the MovieLens dataset you want. MovieLens-100k has been added and used for deployment as it is a lightweight option.]
Start the Flask server:
python app.pyOpen the frontend in your browser:
http://127.0.0.1:5000
Enter recently watched movies and their ratings to get personalized recommendations.
To train the model, run:
python train.pyTo evaluate the model, run:
python evaluate.pyThe application is deployed using Render and is available at movierecommendation-system.onrender.com.
The model's performance is evaluated using metrics such as Mean Absolute Error (MAE) and Root Mean Squared Error (RMSE). Below are the evaluation results:
- Test Loss: 0.6128820180892944
- Test Mean Absolute Error (MAE): 0.5911314487457275
- Test Root Mean Squared Error (RMSE): 0.7828662942166503
- Test R²: 0.4531968165906377
These metrics indicate that the model performs well in predicting user ratings for movies.
Below is the architecture of the hybrid GMF-MLP model used in this recommendation system:
The training history plot shows the model's loss and validation loss over epochs:
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -m "Add your feature" - Push to the branch:
git push origin feature/your-feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- MovieLens.org for providing the dataset.
- Render for deployment.
For questions or feedback, please contact Soudeep Ghoshal.

