Skip to content

Cheukting/knn_recommender

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

KNN Recommender

By using MovieLens Datasets we build a recommender system based on KNN Item-Based Collaborative Filtering.

Enviroment Setup

Use poetry to set up the Python environment (Python >= 3.9)

Get the full data set from MovieLens Datasets and put the movies.csv and ratings.csv in this repo.

Complete the exercises

Find all the TODO comments in knn_recommender.py and finish the missing pieces in the code. The finished version is in the finished branch

Run in CLI

Run the knn_recommender.py with the following optional options:

  • --movie_name : provide your favoriate movie name
  • --top_n : top n movie recommendations
  • --path : input data path, default to be ./
  • --movies_filename : default to be movies.csv
  • --ratings_filename : default to be ratings.csv

Example:

python knn_recommender.py --movie_name "Iron Man" --top_n 10

Run in Browser

Make sure you have run it once in the CLI and have the pickle files (hashmap.p and movie_user_mat_sparse.p) in this repo

Start a local webserver:

python -m http.server

Open http://0.0.0.0:8000 and select knn_recommender.html from there

Presentation slides

Visit the slides on slides.com


Credit to Kevin Laio (KevinLiao159) for original code and blog post

About

Demo of a knn recommender

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published