Skip to content

Repository files navigation

Recommender Systems — Individual Project

ESADE · Recommender Systems (MAPO_008019, Prof. Marc Torrens) · MSc Business Analytics

A music recommender prototype on the Last.fm HetRec 2011 dataset. It implements the algorithm families taught in the course, behind one common interface, and compares them on the same data with a full accuracy and beyond-accuracy evaluation — surfaced in a Streamlit app.

Goal

Given a listener and their play history, recommend new artists they'll likely love but haven't discovered yetdiscovery, not search, across a ~17k-artist long tail. Each algorithm is a different way of estimating the same utility S(user, artist); the app lets you pick a user, see each method's top-N with explanations, and compare their quality and character.

Methods (mapped to the syllabus)

Module Method Syllabus topic
non_personalised most-popular / mean pseudo-rating 1. Intro
user_cf user-user CF, Pearson, mean-centred 2a
item_cf item-item CF, adjusted cosine 2b
matrix_fact SVD latent factors 2c
content_based TF-IDF over tags + cosine 3. Content-based

Evaluation (topic 4): MAE/RMSE, Precision@k, Recall@k, NDCG, MRR + diversity, novelty, catalog coverage, popularity bias — all vs random & most-popular baselines.

Key design decisions

  • Implicit → pseudo-ratings. Last.fm has play counts, not 1-5 ratings. We map log1p(plays) then per-user min-max scale to [1, 5], so the taught rating-prediction formulas and MAE/RMSE apply directly. (data_loader.py)
  • Library: scikit-surprise — maps 1:1 to the syllabus (KNNWithMeans = user/item CF, SVD = matrix factorization, built-in MAE/RMSE).
  • Split: per-user temporal (primary). The listening file has no timestamps, but tag assignments do — we derive each interaction's time from the earliest tag date and hold out each user's temporally-latest interactions (train on the past, test on the future). Undated listening is treated as known background history. A per-user random split is kept as a "temporal vs random" comparison. (split.py)

Layout

config.py          # paths + parameters
data_loader.py     # raw .dat -> per-user pseudo-ratings
split.py           # reproducible per-user train/test split
recommenders/      # the five algorithm modules (common .fit/.recommend interface)
evaluation/        # accuracy + beyond-accuracy metrics
streamlit_app/     # the UI
data/raw/          # Last.fm HetRec 2011 files (downloaded)

Run locally

pip install -r requirements.txt
streamlit run streamlit_app/app.py

The dataset downloads itself from GroupLens on first launch (≈2.5 MB), so no manual data setup is needed. To re-run the offline evaluation:

python -m evaluation.evaluate        # writes data/processed/evaluation_results.csv

Note on the URL: streamlit run prints a localhost:8501 address. That only works on the machine running the server — it is not a shareable link. For a public link, use the deployed app below.

Live demo (Streamlit Community Cloud)

The app is deployment-ready. To publish a public URL:

  1. Push this repo to GitHub.
  2. Go to share.streamlit.io and sign in with GitHub.
  3. New app → pick this repo → set Main file path to streamlit_app/app.pyDeploy.

Models are fitted lazily (only the methods you view), so the default app stays within Cloud memory limits. The item-item CF model builds a large similarity matrix and is best run locally.

Data

Last.fm HetRec 2011 (hetrec2011-lastfm-2k): 1,892 users · 17,632 artists · 92,834 listening events · 11,946 tags. Released for non-commercial use by GroupLens; downloaded at runtime rather than committed to the repo.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages