The Recommender Systems category page had no intro, showing only the table with a generic meta description. Co-Authored-By: Claude <noreply@anthropic.com>
2.4 KiB
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
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.