Recommender Systems

Libraries for building recommender systems.

Match the Python recommender system library to your data: Surprise if users rate items, implicit if they only buy or watch. Annoy finds similar items fast.

How to choose:

  • Ratings users give, like 1 to 5 stars: Surprise
  • Purchases, watches, or page views, with no ratings: implicit
  • Fast lookups of similar items from a trained model: Annoy

Listed in editorial order. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags
Approximate Nearest Neighbors in C++/Python optimized for memory usage.
spotify/github.com/spotify/annoy /14,329 stars /
A fast Python implementation of collaborative filtering for implicit datasets.
benfred/github.com/benfred/implicit /3,834 stars /
A scikit for building and analyzing recommender systems.
NicolasHug/github.com/NicolasHug/Surprise /6,824 stars /

Recommender Systems guide

Surprise is built for explicit rating data, and it doesn't support implicit ratings. Its basic usage cross-validates an algorithm like SVD on a built-in dataset in a few lines of code. For your own ratings, define a Reader and load them from a file or a pandas dataframe. Surprise predicts ratings, so to recommend items, predict the ratings a user hasn't given and keep the top N.

implicit offers fast Python implementations of popular algorithms for implicit feedback datasets, such as Alternating Least Squares and Bayesian Personalized Ranking. Every model implements one interface for training and recommending. Train with fit on a sparse CSR matrix of users by items, whose values are how confident you are that the user likes each item. Then recommend returns items for a user, and similar_items finds related items.

Annoy is a C++ library with Python bindings that searches for points close to a query point. For recommendations, it runs after matrix factorization: every user and item becomes a vector, and Annoy finds similar ones. Its indexes are static files, so you build an index once and save it, and every process loads it with mmap and shares the same data.

implicit and Annoy work together: implicit can use an Annoy index to speed up recommend and similar_items on any matrix factorization model, at the risk of missing some relevant results.

Know a project that belongs here?

Tell us what it does and why it stands out.