Skip to main content

LightFM recommendation model - Python 3.12+ compatible fork

Project description

LightFM Next

LightFM logo

A Python 3.12+ compatible fork of the original LightFM recommendation library.

Build status
Linux & macOS (3.8-3.12) GitHub Actions

PyPI

Note: This is a community-maintained fork that provides Python 3.12+ compatibility by fixing Cython 3.0+ build issues. All credit goes to the original LightFM authors. If you're using Python < 3.12, consider using the original LightFM package.

LightFM is a Python implementation of a number of popular recommendation algorithms for both implicit and explicit feedback, including efficient implementation of BPR and WARP ranking losses. It's easy to use, fast (via multithreaded model estimation), and produces high quality results.

It also makes it possible to incorporate both item and user metadata into the traditional matrix factorization algorithms. It represents each user and item as the sum of the latent representations of their features, thus allowing recommendations to generalise to new items (via item features) and to new users (via user features).

For more details, see the Documentation.

Need help? Contact me via email, Twitter, or Gitter.

Installation

For Python 3.12+

Install lightfm-next from PyPI:

pip install lightfm-next

Note: Windows support is not available yet. Use Linux or macOS.

For Python < 3.12

Use the original LightFM package:

pip install lightfm

or Conda:

conda install -c conda-forge lightfm

Migration from original LightFM

lightfm-next is a drop-in replacement for the original LightFM. Simply replace your installation:

# Replace this
pip uninstall lightfm
pip install lightfm-next

No code changes required - all imports and APIs remain identical:

from lightfm import LightFM  # Works exactly the same

Quickstart

Fitting an implicit feedback model on the MovieLens 100k dataset is very easy:

from lightfm import LightFM
from lightfm.datasets import fetch_movielens
from lightfm.evaluation import precision_at_k

# Load the MovieLens 100k dataset. Only five
# star ratings are treated as positive.
data = fetch_movielens(min_rating=5.0)

# Instantiate and train the model
model = LightFM(loss='warp')
model.fit(data['train'], epochs=30, num_threads=2)

# Evaluate the trained model
test_precision = precision_at_k(model, data['test'], k=5).mean()

Articles and tutorials on using LightFM

  1. Learning to Rank Sketchfab Models with LightFM
  2. Metadata Embeddings for User and Item Cold-start Recommendations
  3. Recommendation Systems - Learn Python for Data Science
  4. Using LightFM to Recommend Projects to Consultants

How to cite

Please cite LightFM if it helps your research. You can use the following BibTeX entry:

@inproceedings{DBLP:conf/recsys/Kula15,
  author    = {Maciej Kula},
  editor    = {Toine Bogers and
               Marijn Koolen},
  title     = {Metadata Embeddings for User and Item Cold-start Recommendations},
  booktitle = {Proceedings of the 2nd Workshop on New Trends on Content-Based Recommender
               Systems co-located with 9th {ACM} Conference on Recommender Systems
               (RecSys 2015), Vienna, Austria, September 16-20, 2015.},
  series    = {{CEUR} Workshop Proceedings},
  volume    = {1448},
  pages     = {14--21},
  publisher = {CEUR-WS.org},
  year      = {2015},
  url       = {http://ceur-ws.org/Vol-1448/paper4.pdf},
}

Development

Pull requests are welcome. To install for development:

  1. Clone the repository: git clone https://github.com/midodimori/lightfm-next.git
  2. Install UV: curl -LsSf https://astral.sh/uv/install.sh | sh
  3. Install dependencies: cd lightfm-next && uv sync --extra dev --extra lint
  4. Run all tests and linting: make test-all

Available make commands:

  • make install - Install dependencies and build extensions
  • make lint - Run flake8 linting
  • make test - Run pytest
  • make test-basic - Run basic functionality test
  • make test-all - Run complete test suite (same as CI)

When making changes to .pyx extension files, run uv run python setup.py build_ext --inplace to rebuild extensions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightfm_next-1.18.10.tar.gz (428.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lightfm_next-1.18.10-cp313-cp313-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

lightfm_next-1.18.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

lightfm_next-1.18.10-cp313-cp313-macosx_11_0_arm64.whl (551.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lightfm_next-1.18.10-cp313-cp313-macosx_10_13_x86_64.whl (550.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

lightfm_next-1.18.10-cp312-cp312-musllinux_1_2_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

lightfm_next-1.18.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lightfm_next-1.18.10-cp312-cp312-macosx_11_0_arm64.whl (552.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lightfm_next-1.18.10-cp312-cp312-macosx_10_13_x86_64.whl (551.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

Details for the file lightfm_next-1.18.10.tar.gz.

File metadata

  • Download URL: lightfm_next-1.18.10.tar.gz
  • Upload date:
  • Size: 428.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lightfm_next-1.18.10.tar.gz
Algorithm Hash digest
SHA256 a096f9fc244eb9d5185ad95252faa171194714e7ab0b89a4809b3a4e7071470c
MD5 e191c7165eeb12afb2a72f0137b45555
BLAKE2b-256 d19533af7ae5f769d13f5f78931a1642b0236637574ce6717e7529d48bebecb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10.tar.gz:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2fcf51239a5f4d03e43945e59a718855680de72f14425d837106e6613ca150c0
MD5 2ec7ff0f9d81176c8e1488c8be574253
BLAKE2b-256 3e6bf6bda386319d49a3cab02bb9e5affe62b38c1db5c0bd21688e92f0086db3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b3b9fbbffcd052c7458b5c85fed015570cb381b82325ed810e1bd3bbde9f2de
MD5 694f359763e68b29da281ec7ff44e419
BLAKE2b-256 e6d926b17bddc0b6030757008f9038ed296e8e3252060005b544f112705411a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a506ed4656e0681fd44b7221b2342d09731dda2cd950b5fe2a466a38dc9aaf0d
MD5 10083de771c5380df6ebc4b2b1addb52
BLAKE2b-256 747aa0a6846d67f3fd763159cd71e7e0a713476bb421c5b7bc96025f93eb2cf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d30e3cc4eb71c1fb00eb0a5d27ea2d906654ad0acd057e16d7c2c3846620ce29
MD5 3c64435bf68aae2061598e16411b97fa
BLAKE2b-256 cb8559bf57e6e2cfacc64f23decd7e463c403d13609b874e3d65dfb2ab08f509

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7e4fb58065bc58df18ad8c9f871df66464c76fdd03aa9d3dded3eaa07395bb6a
MD5 bcbf4f3a073c514645b50b726bfca026
BLAKE2b-256 ee24423a85b93baa27a8ca676f4b7d4da6c91cafc18a72f92ac0c0e559c5a34d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a292e8229b8a968dd214c12d89f41017986c493225d487196b1938f2f083e68
MD5 6032af0b126ce4b61437de86ef16d4d9
BLAKE2b-256 1b116c0a689ebde622b0f8945825580ab073b07c81ef51a52900123f87afe3e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddf39879bf10f0a7e05ba45bfa1ebbafd0d29b982f0f4c9b8b3c4e0dc7cdbdb5
MD5 e4c7b64b36bf0d7062b81b4fc8ccc179
BLAKE2b-256 5ba22572d20c108cd8a2b1ab254a88d9c7105311f1a1ec25a421fc85b025b786

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightfm_next-1.18.10-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.18.10-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 64652e7d3fdb350a09eb15074ed398509a994d0e189153720cad27b612d1ed49
MD5 ec677c5a5c84ff01f63f2ffba1ea27f3
BLAKE2b-256 36ceb0f77fac9a8c4ebc40752e36f083cb14241745ec55d2235ddd642dd58646

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.18.10-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: publish.yaml on midodimori/lightfm-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page