A webapp for movie recommendations made via two different models (NMF and KNN)
This webapp provides a simple interface for two movie recommender systems:
- Based on the user's ratings on five different movies, the first recommender uses Collaborative Filtering with Non-Negative Matrix Factorization (NMF) to suggest another five titles.
- The second recommender just asks for the title of the user's favourite movie, and uses Item-Based Collaborative Filtering with K-Nearest Neighbours (KNN) and Cosine Similarity to produce a list of ten similar movies.
Also features a function to automatically update and refine the NMF model every 12 hours on the basis of the ratings input by the webapp's users.
This project is based on the MovieLens 100k Dataset. Click here for more information.
If you use MacOs or Linux, clone this repository and cd
into the folder recommender_app
. Then follow these simple steps:
-
Install the required Python libraries with
pip install -r requirements.txt
. -
Generate the NMF trained models by running
python movie_recommender.py
. The process may take a few minutes, but the module also takes care of starting the webapp once the training phase achieved:- When your Terminal prints
Now starting the Flask app
, open the addresshttp://localhost:5000
in your browser for using the webapp, then follow the instructions on the CLI to decide whether to enable the automatic retraining of the models based on the ratings provided by the app's users or not.
⚠️ ⚠️ On some Linux versions, you may need toapt install lsof
before running themovie_recommender
module. - When your Terminal prints
-
Once the NMF-model files generated, you can always access the webapp by running
python movies_app.py
.
P.S.: If you prefer to use Docker
, just follow the instructions in the following paragraph.
You may recur to WSL
, but the simplest way is probably to use Docker
. All you have to do is:
-
cd
into the folderrecommender_app
. -
Build the image from the provided Dockerfile by running
docker build . -t movies
. -
Create and start a container by running
docker run -ti -p 5000:5000 --name recommender movies
. You will get access to the container's Bash Command Line. -
Run
python movie_recommender.py
. Refer to point 2 of the previous paragraph for the next steps and options. The webapp will be available athttp://localhost:5000
. -
To quit the container's environment and CLI, you may use the command
exit
.
The code in this repository is an extended and reworked version of the original project developed in collaboration with Behzad Azarhoushang and Laura Bartolini.
- Improve the CSS of the website.
- Show the movie posters of the recommended movies.
- Tests.