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.19.0.tar.gz (426.2 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.19.0-cp313-cp313-musllinux_1_2_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

lightfm_next-1.19.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

lightfm_next-1.19.0-cp313-cp313-macosx_11_0_arm64.whl (541.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lightfm_next-1.19.0-cp313-cp313-macosx_10_13_x86_64.whl (543.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

lightfm_next-1.19.0-cp312-cp312-musllinux_1_2_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

lightfm_next-1.19.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lightfm_next-1.19.0-cp312-cp312-macosx_11_0_arm64.whl (542.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lightfm_next-1.19.0-cp312-cp312-macosx_10_13_x86_64.whl (544.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: lightfm_next-1.19.0.tar.gz
  • Upload date:
  • Size: 426.2 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.19.0.tar.gz
Algorithm Hash digest
SHA256 2f02e0b1bc1338373d3086773e258b2bbee98352818bbba189a15ce7111f3781
MD5 ca6fcc972d6ad498cf945bc317251e8c
BLAKE2b-256 d22e964b86556b19d8bef7866f69730514e7a538fa7e196ddbd8df9bc358de02

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0.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.19.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a5623db43e40c16782110a371d2b22e150dbf59feb0d6df2df8ce72b6e58389b
MD5 b251b389bf2141c51752b6a77498ba0e
BLAKE2b-256 87ee6709aaa2aa4f65b5bc640f4394532d4ec873b0db401bdbe8fbe1c96e9e17

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a78fe727d8aa28992fb6735f44d67c95841c06008221cb203e80430657504cde
MD5 f6539f994668b7bf83c52c3bc665357e
BLAKE2b-256 156455cb91edadd4e14f00c001b0b439e755081c0ba6f693e149866e8583f84d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c74d6741df62b9ece1212bb856a5964387eccec00bc2eb55681fd94f291510b3
MD5 91cb357bc2c934e2072c30f927966a7a
BLAKE2b-256 5e3a488c528e11b3b4216b0e7b8ba935c3b928cb4c8b42658384f06c6444c2ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c05e8a8ed2504dc03150d0965ab918b1e7d4360c02ed72fafcb84d64d117e910
MD5 d791783927595ac0394ee8d26c1c2ac4
BLAKE2b-256 7285c6d8fc714f75d509bbce3ba10e44a78ec41fa7a00b9b02944b9247c504d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2ca2b3e4b3d931426ac343232797c8c6c56bee6fce499019c4b637827ac8af9d
MD5 1469529c954a19898536c6da8eff691b
BLAKE2b-256 b868e2555d87f85a79eba0ab6f164e3f2a91c8659fdf048ce54bead527880834

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84d81163ef06b21a90d28596417e81422460a16925cd2bd6143b34da9146c12f
MD5 ad4b20fd36084d98e1cccfdab2a3e0cd
BLAKE2b-256 84bd18c6bc6c16e91028d1725a8e185f6465afb379b53effde485cc3bca28a42

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 262264c53274d78557bcf7c9e47c3b46baa7033612ab88ee56510506074cd68a
MD5 88cf3284fc6914bafc6e880bf6c95cbb
BLAKE2b-256 0d89f8a0f26ba22753b627d82b19fcee53a5fb6c992796b63482b52654c0eaea

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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.19.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for lightfm_next-1.19.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 eef6d3894515ecfba44ce72f1a346d9d0f995e2ea2352b06fb55bc9e06e7af76
MD5 f254bfb5492c6e9d893fee2849e09a9a
BLAKE2b-256 0645008eb39c8b2b8ce26fa5d87646798b39827320793e7794bfb8e4dc81dc0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for lightfm_next-1.19.0-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