> For the complete documentation index, see [llms.txt](https://www.mlcompendium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.mlcompendium.com/ai-product/recommender-systems.md).

# Recommender Systems

Users need a next item, and a recommender has to predict which one. The page starts with the recommendation task itself (content-based methods, collaborative filtering, and matrix factorization), then asks how to evaluate those systems, and ends with the tools that implement them.

The same notes are in [Embedding](/deep-learning/representations.md), [Multi Armed Bandits](/decision-intelligence/multi-armed-bandits.md), [SIMILARITY](/data/processing-intro/feature-engineering.md#similarity), [SVD](/predictive-ml/dimensionality-reduction-methods.md#svd), and [TF-IDF](/natural-language-processing-nlp/tf-idf.md).

## The recommendation task

The task has two classic answers: recommend items similar to what the user liked, or recommend what similar users liked. The first is content-based. [Beginner guide](https://www.analyticsvidhya.com/blog/2015/08/beginners-guide-learn-content-based-recommender-systems/) is Shuvayan's guide to content based recommender systems, their workings, applications, and limitations, with a step-by-step build. The second is collaborative filtering, and [Real python on CF](https://realpython.com/build-recommendation-engine-collaborative-filtering/#steps-involved-in-collaborative-filtering) walks the steps involved in it. [Intro to, using item-item or user-item](https://www.ethanrosenthal.com/2015/11/02/intro-to-collaborative-filtering/) is Ethan Rosenthal's introduction, written because he found Andrew Ng's course lacking on recommender systems, which he sees as completing the triumvirate of machine learning pillars for data science after regression and classification.

The simplest content-based version is Tfidf cosine similarity, and [countvec cosine](https://www.datacamp.com/community/tutorials/recommender-systems-python) is the DataCamp beginner tutorial on recommender systems in Python that shows it. Various implementations of CF; a serious review of algorithms is listed in the tools section below. [Collaborative filtering, SVD](https://hackernoon.com/introduction-to-recommender-system-part-1-collaborative-filtering-singular-value-decomposition-44c9659c5e75) is HackerNoon's introduction, which defines a recommender system as one that predicts the future preference of a set of items for a user and recommends the top items, needed because the Internet gives people too many options; the same piece is listed as [Part1,](https://hackernoon.com/introduction-to-recommender-system-part-1-collaborative-filtering-singular-value-decomposition-44c9659c5e75) of the series. The DataCamp tutorial is also [A general tutorial, has a nice intro](https://www.datacamp.com/community/tutorials/recommender-systems-python).

Movies are the standard playground. Medium on Movies was a three-part series (Part 1 matrix factorization in movies, users vs movies; Part 2 using collaborative filtering using open ai; Part 3 using col-filtering with neural nets), and its sources are kept at the end of the page. The Medium series on collaborative filtering and embeddings Part 1, part 2 is also gone, but its [git](https://github.com/shik3519/collaborative-filtering) repo remains. [Movie recommender systems](https://www.kaggle.com/rounakbanik/movie-recommender-systems) is a Kaggle notebook using data from The Movies Dataset, and the basics of recommendation models are [On git](https://github.com/jaypatel00174/Movie-Recommendation).

Matrix factorization is the next step past neighbours; its summary is kept at the end of the page. Real data is often binary rather than rated: [Collaborative filtering with binary countvec data, item-item, didnt work well on another domain](https://medium.com/radon-dev/item-item-collaborative-filtering-with-binary-or-unary-data-e8f0b465b2c3) is a simple, non state of the art write-up of item-item collaborative filtering with binary or unary data, since most examples use the MovieLens 1–5 star ratings. The Netflix competition, matrix factorization over classical algorithms, a survey paper, and Movie similarity based on genre used to sit here and are kept at the end of the page.

Similarity at scale is its own problem. [Similar entities, matrix multiplication](https://medium.com/wbaa/https-medium-com-ingwbaa-boosting-selection-of-the-most-similar-entities-in-large-scale-datasets-450b3242e618) high sparsity: comparing very large feature vectors usually means a sparse matrix multiplication followed by selecting the top-n results, and a customized Cython function improves speed by about 40% over SciPy and NumPy. The distance itself also breaks down: [Euclidean distance with high sparse data](https://stats.stackexchange.com/questions/117354/euclidean-distance-with-sparse-and-high-dimension-data) is the question of comparing objects built from texts whose length varies a lot.

To build one yourself, Excel & fastai Excel fastai [git](https://github.com/shik3519/collaborative-filtering/blob/master/cf-scratch-movielens/collaborative%20filtering%20from%20scratch.ipynb) is collaborative filtering from scratch on MovieLens, implemented with fastai and pytorch. [CF for movie recommendation](https://medium.com/@wwwbbb8510/python-implementation-of-baseline-item-based-collaborative-filtering-2ba7c8960590) is Bin Wang's Python implementation of baseline item-based collaborative filtering, and its related article is the [Comparison item vs user cf](https://medium.com/@wwwbbb8510/comparison-of-user-based-and-item-based-collaborative-filtering-f58a1c8a3f1d). The Real Python piece in full is [build a recommendation engine with collaborative filtering](https://realpython.com/build-recommendation-engine-collaborative-filtering/).

## Evaluating Recommender Systems

Once recommenders exist, the question is which one is better, for the business and for accuracy.

The same notes are in [Evaluation Metrics](/evals/evaluation-metrics.md).

An exhaustive list of methods to evaluate used to open this list and is kept at the end of the page. For the business view, [Choosing the best for your business](https://medium.com/recombee-blog/evaluating-recommender-systems-choosing-the-best-one-for-your-business-c688ab781a35) starts from the rise of Software-as-a-Service recommender systems, which are no longer a privilege of large companies building their own in-house. [Evaluating](https://medium.com/the-owl/evaluating-recommender-systems-749570354976) is Saumyadeepta Sen's post on the metrics used for recommender systems, after earlier posts on classification metrics. The accuracy side is formalized in the [survey of accuracy eval metrics for RS by Microsoft](https://www.jmlr.org/papers/volume10/gunawardana09a/gunawardana09a.pdf). Metrics then need a process: [Building a validation framework](https://medium.com/moosend-engineering-data-science/building-a-validation-framework-for-recommender-systems-a-quest-ec173a24b56f) is Dimitris Apostolopoulos on building a validation framework for a recommender system. Evaluation Metrics for RS is kept at the end of the page. The hardest case is having no history at all: [offline vs online validation](https://www.quora.com/How-do-I-validate-my-recommendation-system-without-prior-user-interaction-data) answers how to validate a recommendation system without prior user interaction data, including a detailed rebuttal of a paper on how much traffic recommenders actually cause. [Evaluating RS](https://tzin.bgu.ac.il/~shanigu/Publications/EvaluationMetrics.17.pdf) is the paper for a designer choosing between candidate approaches, where the first step is deciding which properties of the application matter.

## TOOLS

After evaluation, the work is implementation, and the tools here are Surprise, Grover Prince’s repo, and python-recsys.

[Surprise](https://github.com/NicolasHug/Surprise) is a Python scikit for building and analyzing recommender systems, and its [docs](https://surprise.readthedocs.io/en/stable/FAQ.html#how-to-get-the-top-n-recommendations-for-each-user) FAQ shows how to get the top-N recommendations for each user. The related article for Grover Prince's notes for machine learning is [Grover prince](https://github.com/groverpr/Machine-Learning). [Recsys](https://github.com/ocelma/python-recsys) is a python library for implementing a recommender system.

Various implementations of CF are compared in the Towards Data Science article <https://towardsdatascience.com/various-implementations-of-collaborative-filtering-100385c6dfe0>, which is also the related article for the repos above: <https://towardsdatascience.com/various-implementations-of-collaborative-filtering-100385c6dfe0>

[Body Transformation Product Recommendation Using Gen-AI](https://cohenori.medium.com/body-transformation-product-recommendation-using-gen-ai-d5f294442ec4) (August 2025) is a recommender built as a product.

## Deprecated links

{% hint style="warning" %}
These links and images no longer work. The original wording is kept here. A same-resource copy, when one was checked, is used above.
{% endhint %}

* Tfidf cosine similarity. This address no longer opens: <https://towardsdatascience.com/recommender-engine-under-the-hood-7869d5eab072>
* Spotlight, item2vec, Neural nets for Recommender systems. This address no longer opens: <https://towardsdatascience.com/introduction-to-recommender-system-part-2-adoption-of-neural-network-831972c4cbf7>
* Part 1 matrix factorization in movies, users vs movies. This address no longer opens: <https://towardsdatascience.com/fast-ai-season-1-episode-5-1-movie-recommendation-using-fastai-a53ed8e41269>
* Part 2 using collaborative filtering. This address no longer opens: <https://towardsdatascience.com/fast-ai-season-1-episode-5-2-collaborative-filtering-from-scratch-1877640f514a>
* Part 3 using col-filtering with neural nets. This address no longer opens: <https://towardsdatascience.com/fast-ai-season-1-episode-5-3-collaborative-filtering-using-neural-network-48e49d7f9b36>
* Medium series on collaborative filtering and embeddings Part 1. This address no longer opens: <https://towardsdatascience.com/collaborative-filtering-and-embeddings-part-1-63b00b9739ce>
* part 2. This address no longer opens: <https://towardsdatascience.com/collaborative-filtering-and-embeddings-part-2-919da17ecefb>
* Matrix factorization. This address no longer opens: <https://towardsdatascience.com/paper-summary-matrix-factorization-techniques-for-recommender-systems-82d1a7ace74>
* Netflix competition, matrix factorization over classical algorithms, a survey paper. This address no longer opens: <https://towardsdatascience.com/paper-summary-matrix-factorization-techniques-for-recommender-systems-82d1a7ace74>
* Movie similarity based on genre. This address no longer opens: <https://towardsdatascience.com/content-based-recommender-systems-28a1dbd858f5>
* An exhaustive list of methods to evaluate. This address no longer opens: <https://towardsdatascience.com/an-exhaustive-list-of-methods-to-evaluate-recommender-systems-a70c05e121de>
* Evaluation Metrics for RS. This address no longer opens: <https://towardsdatascience.com/evaluation-metrics-for-recommender-systems-df56c6611093>
* (how to find product relations, important: creating negative samples). This address no longer opens: <https://eugeneyan.com/2020/01/06/recommender-systems-beyond-the-user-item-matrix>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.mlcompendium.com/ai-product/recommender-systems.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
