← All projects
Machine learning & AI · Python
★

recs

Item-item CF, matrix factorisation and BPR on a small embedded catalogue — top-N pages with scores, and the finding that rating prediction does not rank.

01 Recommend for a user

20 users × 25 popular titles sampled from the package's 17k interactions. Seen items are excluded from every page — the best predictor of what someone watched is what someone watched.

History (seen)

    Recommendations item-knn

      02 The rating matrix

      Cells are ratings 1–5; blank means unseen. This is a dense sample so the demo runs instantly — the real matrix is 11.5% full across 500 users and 300 items.

      03 Rating prediction is not ranking

      On the full dataset, MatrixFactorization minimises squared error on observed ratings — the classic Netflix-prize objective — and scores well at exactly that. Ranked by its predicted rating it collapses: the highest predictions go to items a handful of generous users rated 5, which almost nobody else wants.

      BPR is the same architecture with the ratings thrown away. For each thing a user interacted with, sample something they did not, and push the first above the second. Same factors, same regularisation, same data: NDCG@10 0.0138 → 0.1878, a factor of thirteen.

      Also fixed in the package: a temporal split per user (never random), seen items excluded from every page, and coverage reported next to accuracy — popularity reaches 10.7% of the catalogue; BPR reaches 97%.

      32 tests · Python 3.10–3.12 · no runtime dependencies · Built by Umer Hashmi