- Notifications
You must be signed in to change notification settings - Fork71
Python recommendation toolkit
License
lenskit/lkpy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
LensKit is a set of Python tools for experimenting with and studying recommendersystems. It provides support for training, running, and evaluating recommenderalgorithms in a flexible fashion suitable for research and education.
LensKit for Python (LKPY) is the successor to the Java-based LensKit project.
Important
If you use LensKit for Python in published research, please cite:
Michael D. Ekstrand. 2020.LensKit for Python: Next-Generation Software for Recommender Systems Experiments.In Proceedings of the 29th ACM International Conference on Information and Knowledge Management (CIKM '20).DOI:10.1145/3340531.3412778.arXiv:1809.03125 [cs.IR].
Note
LensKit had significant changes in the 2025.1 release. See theMigrationGuide for details.
To install the current release withuv
(recommended):
$uv pip install lenskit
Or, to add it to your project's dependencies and virtual environment:
$uv add lenskit
Classicpip
also works:
$python -m pip install lenskit
Then seeGetting Started
You can also install LensKit fromconda-forge
withpixi
:
$pixi add lenskit
Orconda
:
$conda install -c conda-forge lenskit
To use the latest development version, you have two options. You can installdirectly from GitHub:
$uv pip install -U git+https://github.com/lenskit/lkpy
Or you can use our PyPI index, by adding topyproject.toml
:
[[tool.uv.index]]name ="lenskit"url ="https://pypi.lenskit.org/lenskit-dev/"
Binary wheels of LensKit development (and release) versions are automaticallypushed to this index, although they are not guaranteed to be permanentlyavailable. Reproducible code should generally depend on released versionspublished to PyPI.
We also provide mirrors of the PyTorch package repositories that are filtered toonly include PyTorch and directly supporting dependencies, without otherpackages that conflict with or mask packages from PyPI, and with fallbacks forother platforms (i.e., our CUDA indices include CPU-only MacOS packages). Thismakes it easier to install specific versions of PyTorch in your project withthe index priority and fallthrough logic implemented byuv
. To make yourproject only use CPU-based PyTorch, you can add topyproject.toml
:
[[tool.uv.index]]name ="torch-cpu"url ="https://pypi.lenskit.org/torch/cpu/"
Or CUDA 12.8:
[[tool.uv.index]]name ="torch-gpu"url ="https://pypi.lenskit.org/torch/cu128/"
These indices provide the same package distributions as the official PyTorchrepositories (in fact, they link directly to the PyTorch packages). They arejust an alternate index view that reduces some package conflicts.
To contribute to LensKit, clone or fork the repository, get to work, and submita pull request. We welcome contributions from anyone; if you are looking for aplace to get started, see theissue tracker.
Our development workflow is documented inthe wiki; the wiki alsocontains other information ondeveloping LensKit. User-facing documentation isathttps://lkpy.lenskit.org.
We useuv
for developing LensKit and managingdevelopment environments. Ourpyproject.toml
file contains the Pythondevelopment dependencies; you also need a working Rust compiler (typically viarustup
). Before setting up to work on LensKit, youtherefore need:
- Git
uv
rustup
and a working Rust compiler (rustup install stable
)- A working C compiler compatible with Python
- On Windows, this is either Visual Studio (with C++ development) or theVisual C++ Build Tools. See theRustup Windows installinstructions for details.
- On Mac, install Xcode.
- On Linux, see your system package manager instructions.
Windows
On Windows, you can install dependencies (except for the Visual C++ tools) withwinget
:
>winget install Git.Git astral-sh.uv Rustlang.Rustup>rustup install stable-msvc
Mac
On Mac, you can install the dependencies with Homebrew:
$brew install git uv rustup
Once you have the dependencies installed, set up your LensKit developmentenvironment:
$uv venv -p 3.12$uv sync
If you want all extras (may not work on Windows), do:
$uv sync --all-extras
You can then activate the virtual environment to have the tools available andrun tools likepytest
:
$. ./.venv/bin/activate
You should always test your changes by running the LensKit test suite:
pytest tests
If you want to use your changes in a LensKit experiment, you can locally installyour modified LensKit into your experiment's environment. We recommend usingseparate environments for LensKit development and for each experiment; you willneed to install the modified LensKit into your experiment's repository:
uv pip install -e /path/to/lkpy
This material is based upon work supported by the National Science Foundationunder Grant No. IIS 17-51278. Any opinions, findings, and conclusions orrecommendations expressed in this material are those of the author(s) and do notnecessarily reflect the views of the National Science Foundation.
About
Python recommendation toolkit
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors15
Uh oh!
There was an error while loading.Please reload this page.