Skip to content
Fast Python Collaborative Filtering for Implicit Feedback Datasets
Python Cuda C++ C
Branch: master
Clone or download
chedatomasz and benfred Fixed error reported in issue #264 (#271)
Handle empty matrices in BPR / fix CUDA memory leak

* Fixed error reported in issue #264
* Add a fix for memory leak on cuda: Issue #298
Latest commit 42df436 Nov 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmarks Bayesian Personalized Ranking Feb 8, 2018
docs Add description of LMF to documents. (#248) Aug 7, 2019
examples Revert "Add validation for als, bpr, and lmf (#282)" Oct 25, 2019
tests Fixed error reported in issue #264 (#271) Nov 18, 2019
.gitignore CUDA calculate_training_loss function Nov 17, 2017
.travis.yml Revert "Add validation for als, bpr, and lmf (#282)" Oct 25, 2019
LICENSE Initial commit Apr 17, 2016 use recursive-exclude in Feb 8, 2018 Add factor based recommendation algorithm Logistic Matrix Factorizati… Jul 14, 2019
appveyor.yml Fix Travis build Error (#219) Jun 21, 2019 Revert "Add validation for als, bpr, and lmf (#282)" Oct 25, 2019
requirements.txt use for progress bars Jul 27, 2019
setup.cfg Revert "Merge pull request #285 from ita9naiwa/master" Oct 25, 2019 Revert "Merge pull request #285 from ita9naiwa/master" Oct 25, 2019
tox.ini remove annoy dependency May 15, 2017


Build Status Windows Build Status

Fast Python Collaborative Filtering for Implicit Datasets.

This project provides fast Python implementations of several different popular recommendation algorithms for implicit feedback datasets:

All models have multi-threaded training routines, using Cython and OpenMP to fit the models in parallel among all available CPU cores. In addition, the ALS and BPR models both have custom CUDA kernels - enabling fitting on compatible GPU's. Approximate nearest neighbours libraries such as Annoy, NMSLIB and Faiss can also be used by Implicit to speed up making recommendations.

To install:

pip install implicit

Basic usage:

import implicit

# initialize a model
model = implicit.als.AlternatingLeastSquares(factors=50)

# train the model on a sparse matrix of item/user/confidence weights

# recommend items for a user
user_items = item_user_data.T.tocsr()
recommendations = model.recommend(userid, user_items)

# find related items
related = model.similar_items(itemid)

The examples folder has a program showing how to use this to compute similar artists on the dataset.

For more information see the documentation.

Articles about Implicit

These blog posts describe the algorithms that power this library:

There are also several other blog posts about using Implicit to build recommendation systems:


This library requires SciPy version 0.16 or later. Running on OSX requires an OpenMP compiler, which can be installed with homebrew: brew install gcc. Running on Windows requires Python 3.5+.

GPU Support requires at least version 8 of the NVidia CUDA Toolkit. The build will use the nvcc compiler that is found on the path, but this can be overriden by setting the CUDAHOME enviroment variable to point to your cuda installation.

This library has been tested with Python 2.7, 3.5, 3.6 and 3.7 on Ubuntu and OSX, and tested with Python 3.5 and 3.6 on Windows.


Simple benchmarks comparing the ALS fitting time versus Spark and QMF can be found here.

Optimal Configuration

I'd recommend configuring SciPy to use Intel's MKL matrix libraries. One easy way of doing this is by installing the Anaconda Python distribution.

For systems using OpenBLAS, I highly recommend setting 'export OPENBLAS_NUM_THREADS=1'. This disables its internal multithreading ability, which leads to substantial speedups for this package. Likewise for Intel MKL, setting 'export MKL_NUM_THREADS=1' should also be set.

Released under the MIT License

You can’t perform that action at this time.