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.4.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.4-cp310-cp310-win_amd64.whl (21.4 MB view details)

Uploaded CPython 3.10Windows x86-64

lme_python-0.2.4-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.4-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.4-cp310-cp310-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lme_python-0.2.4-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.4.tar.gz.

File metadata

  • Download URL: lme_python-0.2.4.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.4.tar.gz
Algorithm Hash digest
SHA256 443c422cb73f417364b826045bb5e1a86f4324e1a80401cc9b22daf518d3846c
MD5 0665b7527129bcf57c0d87a6dd68a0f7
BLAKE2b-256 a50ceb4e4ea2934dafd055461d1f02b6dff9a0667162e28deda3911b3c337b82

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4.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.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lme_python-0.2.4-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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f8d15b3f2b1bbf5bebe7d78d05d770eb08d5e1b29fb803a86d6c41255f05d9f5
MD5 122f9177b61b84fb5f616a0745569fab
BLAKE2b-256 2568c776ffb579e166ceb6dbf541f141d29f6a869f6db96527fb97660151bd68

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4-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.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67d8df69cd59e297d35575948d4108296c23d5134791bf425541136ae23d0b04
MD5 08fe325554451a8490a7c5d892ce9c82
BLAKE2b-256 242a5da994800daa934cc320ccd892d7a6102ce847e4b2879dc6d21d5e80b37c

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4-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.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0a5031828e9abd7c55588992017c8d4ed4b857fd588e1d8e9b25417077542aa2
MD5 262c35bb4d7355b6dbdd9896496a18fe
BLAKE2b-256 863304f5c3c0a0352741df28a363ee930ddedada6bb722ed0c21904ece1d5377

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4-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.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6773074fb0a9d10722779c88e220702fbca9c886ffb786df93058757f5c3236a
MD5 209ba912c5aa70942e7d4eca08153fbd
BLAKE2b-256 5906f19a0c35f116c8369a0af5f1d6f8cdbb442c2d2b3760f449055e7ead120e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4-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.4-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for lme_python-0.2.4-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 27a2391c80d5eaad74bd6b2c7e69534edccafe78939d03426d8649c6266c0492
MD5 554edbc5991342f4b1aed8a522c6400d
BLAKE2b-256 069a3019b9e65aef8b132cd1f8610c3987e5c96aae04d0dfe30c5844f6ca766f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lme_python-0.2.4-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

0.2.5

6 files

This release

0.2.4 This release

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