chiragvartak/movie-recommender
Movie Recommender
This repository contains the code implementation and demonstration of our movie recommending service. Two algorithms,
corresponding to two different approaches have been implemented:
- Hybrid
- Neural Collaborative Filtering (NCF)
Installation & Setup
Environment
We are using Python 3 (more specifically, Python 3.8). Nevertheless, any Python>=3.5 should work fine since we are not
using any version-specific functionalities.
Install the dependencies
pip install matplotlib numpy pandas scikit-learn scikit-surprise Flask flask-restful flask-cors torch torchvision pytorch-lightningThe above command will install the most recent version of the Python dependencies. If that creates any problems, we have
provided a requirements.txt file so that the exact environment can be emulated.
Download data and model files
-
Download the data files - movies.csv, ratings.csv, tags.csv - from the link below, and place it in the project root
folder:
Data files
You can also download these files directly from the GroupLens official website:
GroupLens MovieLens Dataset
Just unzip the files and place them in the project root folder. -
(Optional) If you do not want to train the model yourself, we have provided pre-trained model so that you can quickly
get started. Place thetrained.modelin thecode/ncffolder, and thehybrid.modelin thecode/hybrid
folder.
trained.model (size ~800 MB)
hybrid.model (size ~130 MB)
Train the models
-
To train the NCF model simply run the
code/ncf/Train.pyfile. This will take some time. The model that will be
generate will be placed in the same folder. -
To train the Hybrid model, run the
code/hybrid/train.pyfile. The trained model will be generated and placed in the
same folder.
Run the application
To run the flask application, execute the main method present in code/ncf/main.py.
This should start the flask application on Port:5000 of your system.
Caveats
-
We observed that PyTorch installation using pip sometimes causes problems. In that case, follow the instructions on
the PyTorch Official Website to install the version that is right for you. -
PyTorch installation using pip sometimes gives some
setup.pyerrors. Just verify that your Python installation is
a 64-bit installation. PyTorch does not work on a 32-bit Python installation on Windows.
UI Application Installation and Setup
Install the dependencies
- Install Node.js from: https://nodejs.org/en/download/
- Open terminal in
code/UIfolder and run the commandnpm installto install all the dependent packages.
Run the app
- Open terminal in the
code/UIfolder and run the commandng serve, this will run the application and serve it on Port : 4200 - Open your browser and navigate to http://localhost:4200
User Id's for testing
When you open the UI application, you will be required to enter the User Id for the user you want to get the recommendations for.
If you use the pre-trained model files, you could use the following user id's to get both NCF and Hybrid recommendations: 2103, 5413, 12, 18768.