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. Starting with 0.2.6, the workflow builds interpreter-specific CPython 3.10–3.14 wheels; source-build CI covers those versions, including 3.14 on Windows and macOS. Older releases (including 0.2.5) only provide CPython 3.10 wheels. If pip falls back to a source build, follow the source setup.

For pandas inputs, install lme-python[pandas] to include PyArrow, which is needed for nullable and categorical pandas columns. See the Python integration guide for sum coding, prediction grids, and new-animal null bootstrap fits.

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

Metadata

Release files for lme-python 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lme-python 0.2.7
File Size Uploaded
lme_python-0.2.7.tar.gz 7.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for lme-python 0.2.7
File
lme_python-0.2.7-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
lme_python-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
lme_python-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
lme_python-0.2.7-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
lme_python-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 55.0 MB

Release files / lme_python-0.2.7.tar.gz

Download URL lme_python-0.2.7.tar.gz
Size 7.4 MB
Tags Source
SHA-256 checksum
How to use checksums
f5c9ced701a95cf12d4ca6877f00edc01b300dece091e5b2b29921bae9010d7d
BLAKE2b-256 checksum
How to use checksums
3a4fb37e080bfc36c961844944be6650f091606433977744129bf9f6d40b42f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / lme_python-0.2.7-cp310-abi3-win_amd64.whl

Download URL lme_python-0.2.7-cp310-abi3-win_amd64.whl
Size 21.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
88f3d79f5e609c52eb13ad83f27b4f4d2bedc4b9dd2480bc9e545d1114451e94
BLAKE2b-256 checksum
How to use checksums
64e1c047aa500c70cf40a94437cd0b4daea7515dd9db78b25e1cd4e71d52890e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / lme_python-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lme_python-0.2.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 9.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4d17e6ed10ccaafc74bb5fa1eb8af2415e8cfc49dafc7144d9a3e53f6fa37e09
BLAKE2b-256 checksum
How to use checksums
fd6cafbc0de79d0cb805dc7b498734093acf2c83617bc1121399b7984976f970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / lme_python-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL lme_python-0.2.7-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 6.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7dac9d23e2d1a559b3cb25f6787d023dadd5d856454083dc0fc6b17d5b754c69
BLAKE2b-256 checksum
How to use checksums
ffc64b819142b79f4a80694b1da00a7a5cc5dd28f961511957c24f9f360acf8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / lme_python-0.2.7-cp310-abi3-macosx_11_0_arm64.whl

Download URL lme_python-0.2.7-cp310-abi3-macosx_11_0_arm64.whl
Size 5.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
30aa172d5447eadaf5d64fe9212091381404935406dd7e9ee39c1ab74e2d2d7b
BLAKE2b-256 checksum
How to use checksums
fce763e558d4e9770df9ec01880e9255b6fd7dce2ee160d551ae1f0dbc3dc111
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / lme_python-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl

Download URL lme_python-0.2.7-cp310-abi3-macosx_10_12_x86_64.whl
Size 5.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
01f121241289f29394025a570ec6f2c08b4f0f5cd30b22101088527808d5c5e3
BLAKE2b-256 checksum
How to use checksums
9cac08eb06dcdd484e5c7d6c1aa00b5c48aac69681c03a2ca2fd3beebc993e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.7 This release

6 release files

0.2.6

26 release files

0.2.5

6 release files

0.2.4

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.1

6 release files

0.1.11

6 release files

0.1.9

6 release files

0.1.8

6 release files

0.1.7

6 release files

0.1.4

6 release files

0.1.3

6 release files

0.1.2

6 release files

0.1.1

6 release 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