Skip to main content

lme-python

Python bindings for lme-rs: linear, generalized linear, and nonlinear mixed-effects models with lme4-style formulas. Fitting runs in the same Rust engine used by the crate.

Python guide · Examples · Workflow scope

Install

python -m pip install lme-python

Install lme-python, import lme_python. Polars is a package dependency. A compatible binary wheel does not require a Rust toolchain or an R installation.

Check the selected version's PyPI files for your Python interpreter, OS, and architecture. The release workflow builds CPython 3.10 wheels; source-build CI tests Python 3.10–3.13. Those tests do not imply that a wheel is published for each tested interpreter. If pip falls back to a source build, follow the source setup.

Quick start

This example needs no repository files:

import lme_python
import polars as pl

data = pl.DataFrame(
    {
        "y": [10.0, 12.0, 13.0, 15.0, 9.0, 11.0, 14.0, 17.0, 8.0, 10.0, 12.0, 14.0],
        "x": [0.0, 1.0, 2.0, 3.0] * 3,
        "group": ["a"] * 4 + ["b"] * 4 + ["c"] * 4,
    }
)
fit = lme_python.lmer("y ~ x + (1 | group)", data=data, reml=True)
print(fit.summary())
print(fit.predict(data))

The formula estimates a shared intercept and slope plus a random intercept for each group. The small synthetic dataset is an API demonstration. predict returns fixed-effects predictions; use predict_conditional when you want the fitted group effects.

Continue your analysis

The bindings expose lm, lmer, glmer, and nlmer, along with prediction, intervals, simulation, grouped cross-validation, bootstrap refits, ANOVA, contrasts, and LMM estimated marginal means.

  • Python guide: data requirements, fitting, inference, and structured results.
  • Type reference: function signatures and result fields.
  • Supported workflows: model-specific scope and limitations.
  • Troubleshooting: installation, data, convergence, and prediction problems.
  • Changelog: release history. Use the matching repository tag for version-specific docs.

Development

See Contributing for the locked development environment and extension build. After building, use uv run --no-sync for examples and tests.

task consumer:smoke builds a wheel, verifies it in isolated environments, and runs portable examples against the installed artifact.

Repeated responses and fit diagnostics

Prepare once when fitting several response vectors against the same design:

prepared = lme_python.prepare_lmer("Reaction ~ Days + (Days | Subject)", data)
control = lme_python.FitControl(max_iterations=2000, require_convergence=True)
fit = prepared.fit(y=data["Reaction"].to_list(), reml=True, control=control)
print(fit.diagnostics)

prepare_lmer(..., weights=...) retains observation precision weights. Responses must contain finite values and match the original row count. Offsets are applied exactly once. prepare_glmer also supports prepared.fit(y=..., control=...). The existing fit_prepared(..., y=..., control=...) and fit_prepared_glmer functions remain available.

FitControl accepts max_iterations, tolerance, max_inner_iterations, starting covariance parameters start, and require_convergence. The iteration limit is per outer search stage. Nonlinear fits use max_inner and max_outer_iters instead. Inspect converged and diagnostics before interpreting a fit; diagnostics report termination, iteration counts, objective value, and requested/effective quadrature.

Conversion serializes columns needed by an explicit formula. Dot formulas retain all columns for expansion. Native fitting releases the interpreter lock; custom Python nonlinear mean callbacks reacquire it while evaluating Python code. Bootstrap generates each response as its worker needs it, retaining only replicate summaries. Thread counts no longer change BLAS/OpenMP process settings. License-File: THIRD_PARTY_NOTICES.md License-File: RELINKING.md License-File: Apache-2.0.txt License-File: BSD-3-Clause-OpenBLAS.txt License-File: GPL-2.0-or-later.txt License-File: LGPL-2.1-only.txt License-File: Intel-Simplified-Software-License.txt

Download files

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

Source Distribution

lme_python-0.2.5.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

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

lme_python-0.2.5-cp310-cp310-win_amd64.whl (21.4 MB view details)

Uploaded CPython 3.10Windows x86-64

lme_python-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

lme_python-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

lme_python-0.2.5-cp310-cp310-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lme_python-0.2.5-cp310-cp310-macosx_10_12_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file lme_python-0.2.5.tar.gz.

File metadata

  • Download URL: lme_python-0.2.5.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lme_python-0.2.5.tar.gz
Algorithm Hash digest
SHA256 be712e50888082d471bcb6c2839ac774063ab6e12aff3279c3ccfcc70c616464
MD5 5093ae07963a1eac9dba3b1cb7718b89
BLAKE2b-256 c4c02057ec3c89cc455fbb2c707dde6fecffc454d4a4e84a2e5e4e30b5a1653d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5.tar.gz:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

File details

Details for the file lme_python-0.2.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lme_python-0.2.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 21.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lme_python-0.2.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8076c6161eeb05007813eafc5d2e7c3faf16f2421a4b2ef07d6e074a17bdd594
MD5 b8e935e74aea68ebf1136a1774c1420c
BLAKE2b-256 dee2e59da402d683897439e31983dc3dfdfa91e0fed3210711d574a6161628b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5-cp310-cp310-win_amd64.whl:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

File details

Details for the file lme_python-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f26a454117616855beefaecc66d65cf81265668b1cd2eb91c3416814bc6def04
MD5 41c7521b71124066e3387a904001cc61
BLAKE2b-256 86e50d88a66e75f05cdcc24ced30692ce86ef4965e49abd9b39b3e463c46148a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

File details

Details for the file lme_python-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ed2eaed56695441d09867b471d6a2dcd5e5611dc470527b5a13209cce6884298
MD5 904c177b1a9466e9f24f73d77dac8d73
BLAKE2b-256 34d14f164cf6c35f41918354b7edf47085748c0b4e94bc2bd49e9f2084a6480b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

File details

Details for the file lme_python-0.2.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af1caaa72a7f3c4b181e9cad77c39ca6a3d3fb42bb88ba1c0bce8091f70bf36d
MD5 767dcee801396f4e866ecc8ec4f97a09
BLAKE2b-256 557d7233365c5a99642f36de43c75c4ccac3f2cf7768b559dca9aba0922795e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

File details

Details for the file lme_python-0.2.5-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.5-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 27b7e8d3b374cb408c90b4da46141f0b3049da2aabab3c4e1aab41831b184217
MD5 c4c15a9023f845e7ffc33bbeedb77c42
BLAKE2b-256 80ace8ce66bc5bdad038a6d9ce648cfbf7eee5eb2e83ddfdd2a0cf35402375ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.5-cp310-cp310-macosx_10_12_x86_64.whl:

Publisher: python-release.yml on x4g4p3x/lme-rs

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

Release history Release notifications | RSS feed

This release

0.2.5 This release

6 files

0.2.4

6 files

0.2.3

6 files

0.2.2

6 files

0.2.1

6 files

0.1.11

6 files

0.1.9

6 files

0.1.8

6 files

0.1.7

6 files

0.1.4

6 files

0.1.3

6 files

0.1.2

6 files

0.1.1

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page