Skip to main content

eALS - Element-wise Alternating Least Squares

Project description

eALS - Element-wise Alternating Least Squares

A Python implementation of the element-wise alternating least squares (eALS) for fast online matrix factorization proposed by arXiv:1708.05024.

Prerequisites

  • Python >= 3.8, < 3.11

Installation

pip install eals

Usage

import numpy as np
import scipy.sparse as sps
from eals import ElementwiseAlternatingLeastSquares, load_model

# batch training
user_items = sps.csr_matrix([[1, 2, 0, 0], [0, 3, 1, 0], [0, 4, 0, 4]], dtype=np.float32)
model = ElementwiseAlternatingLeastSquares(factors=2)
model.fit(user_items)

# learned latent vectors
model.user_factors
model.item_factors

# online training for new data (user_id, item_id)
model.update_model(1, 0)

# rating matrix and latent vectors will be expanded for a new user or item
model.update_model(0, 5)

# current rating matrix
model.user_items

# save and load the model
model.save("model.joblib")
model = load_model("model.joblib")

See the examples directory for complete examples.

Development

Setup development environment

git clone https://github.com/newspicks/eals.git
cd eals
poetry run pip install -U pip
poetry install

Tests

poetry run pytest

Set USE_NUMBA=0 for faster testing without numba JIT overhead.

USE_NUMBA=0 poetry run pytest

To run tests against all supported Python versions, use tox. You may need to add the Python versions in the tox.ini file.

poetry run tox

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

eals_py312-0.9.6.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

eals_py312-0.9.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file eals_py312-0.9.6.tar.gz.

File metadata

  • Download URL: eals_py312-0.9.6.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for eals_py312-0.9.6.tar.gz
Algorithm Hash digest
SHA256 d0ff6eb751176103311d09397ea154ca5405b37f29d1381c3df9d643230fada7
MD5 9a8bd8531fafcd0b11bbfb3bfd42516a
BLAKE2b-256 2f0f94f9381a72a6298faef7247c9e5f5430a7c393b208e5d3f95ddcaa04af9a

See more details on using hashes here.

File details

Details for the file eals_py312-0.9.6-py3-none-any.whl.

File metadata

  • Download URL: eals_py312-0.9.6-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for eals_py312-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 daf952a09459d7d3583730d56c1deb7948d0a1ded0f168ae32d6777597a911fd
MD5 f2ea25a5a1db45f55c7522721615a705
BLAKE2b-256 6e8486e025698a05b51c7656773a238b07db2dd12b96348174288dd67dca7b4a

See more details on using hashes here.

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