Skip to main content

Kamino

Native Python Gaussian linear mixed models with a versioned, tested subset of lme4 compatibility.

Install the kamino-lme distribution; the Python import remains kamino:

python -m pip install kamino-lme

Status: release-hardening pre-alpha; Phase 1, N03, F02, I01, I02, I03, A01, A02, and E02 are complete. The public vertical slice fits a Gaussian model with one grouping structure and either a random intercept, a correlated numeric random intercept/slope, or independent numeric intercept and slope terms, using ML or REML and the owned block backend. The formula path uses one shared model frame, stores group membership plus small row-level covariates, and never constructs a dense random-effects indicator matrix. Numeric and categorical fixed effects, treatment/sum contrasts, one pairwise * expansion, weights, additive offsets, subsets, and explicit missing-row handling are covered by pinned lme4 2.0-6 outputs. Ordinary nested or crossed random-intercept terms use the coupled sparse backend and are verified on Pastes, Penicillin, and InstEval. Ordinary categorical random slopes and rank-deficient fixed effects have pinned fit, prediction, and estimability evidence.

from kamino import lmer

fit = lmer(
    "yield_value ~ 1 + (1 | batch)",
    {
        "yield_value": [1.0, 1.2, 0.8, 3.0, 3.1, 2.9],
        "batch": ["a", "a", "a", "b", "b", "b"],
    },
    reml=True,
)
conditional = fit.predict(mode="conditional")
population = fit.predict(
    {"batch": ["a", "unseen"]},
    mode="population",
)

fit.save("yield-model.kamino")

from kamino import load_model_bundle

saved_model = load_model_bundle("yield-model.kamino")
saved_prediction = saved_model.predict(
    {"batch": ["a", "unseen"]},
    mode="conditional",
    allow_new_groups=True,
)

# sleepstudy_data is a pandas DataFrame with these three columns.
slope_fit = lmer(
    "reaction ~ days + (1 + days | subject)",
    sleepstudy_data,
    reml=True,
)

independent_fit = lmer(
    "reaction ~ days + (1 + days || subject)",
    sleepstudy_data,
    reml=False,
)

crossed_fit = lmer(
    "diameter ~ 1 + (1 | plate) + (1 | sample)",
    penicillin_data,
    reml=True,
)

nested_fit = lmer(
    "strength ~ 1 + (1 | batch/cask)",
    pastes_data,
    reml=False,
)

# Treatment coding is the default; use "sum" explicitly when required.
categorical_fit = lmer(
    "y ~ x * treatment + offset(exposure) + (1 | site)",
    model_data,
    weights=prior_weights,
    offset=argument_offset,
    contrasts={"treatment": "sum"},
    subset=analysis_rows,  # one Boolean per original row
    na_action="omit",  # or the fail-closed default, "error"
)

categorical_random_fit = lmer(
    "y ~ treatment + (1 + treatment | site)",
    model_data,
    contrasts={"treatment": "sum"},
    random_contrasts={"treatment": "sum"},
)

# Simulation mode is explicit; streams do not depend on worker order.
draws = fit.simulate(100, seed=20260915, mode="unconditional")

# The optional private ledger stores responses and outcomes for safe resume.
bootstrap = fit.parametric_bootstrap(
    1000,
    seed=20260916,
    workers=4,
    ledger_path="private-bootstrap-ledger",
)
failure_evidence = bootstrap.failure_accounting()
descriptive_interval = bootstrap.interval(method="percentile")

# Full (theta, sigma) derivatives; inference fails closed at boundaries.
satterthwaite = slope_fit.satterthwaite()
slope_test = satterthwaite.test([0.0, 1.0])
fixed_effects_test = satterthwaite.joint_test([[1.0, 0.0], [0.0, 1.0]])

# KR uses REML; an ML source fit is refitted separately and records provenance.
kr = slope_fit.kenward_roger()
kr_slope = kr.test([0.0, 1.0])
kr_fixed_effects = kr.test([[1.0, 0.0], [0.0, 1.0]])

# Profiles always use an ML baseline and reoptimize nuisance parameters.
profiles = slope_fit.profile(targets=[".sig01", ".sig02", ".sig03", ".sigma", "Days"])
slope_profile_interval = profiles.interval("Days", level=0.95)

# Postfit locks coefficient identity, covariance, and DF into one analysis.
postfit = slope_fit.postfit(inference="satterthwaite", data=sleepstudy_data)
slope_row = postfit.tidy()[1]

# Reference grids require the model-frame predictors because live Kamino fits
# deliberately do not retain caller data.
marginal_means = categorical_fit.postfit(data=model_data).reference_grid(
    specs=["treatment"],
    weights="cells",
)
pairwise = marginal_means.pairwise(adjustment="holm")

# CR2 uses marginal residuals and the fitted marginal covariance target.
cr2 = slope_fit.cluster_robust("Subject", covariance_type="CR2")
robust_slope = cr2.test([0.0, 1.0])
robust_fixed_effects = cr2.test([[1.0, 0.0], [0.0, 1.0]])

The accepted fixed side contains an intercept, additive numeric/categorical identifiers, distinct pairwise a * b expansion, and offset(name). The random side is one intercept, one correlated numeric/categorical intercept/slope, or equivalent independent numeric intercept/slope terms sharing one group. A random-slope predictor must also be a supported fixed effect. Multiple grouping structures accept random intercepts and ordinary categorical slopes; nested slash syntax expands with lme4-compatible term and level ordering. Prediction mode is explicit; conditional prediction rejects unseen groups unless allow_new_groups=True. Safe prediction-only model bundles are supported; training rows and responses are deliberately not stored, so reloading does not support refitting or training prediction. Bundles for nested/crossed, rank-deficient, and categorical-random fits remain fail-closed until the Phase 2 artifact-recovery schema milestone. Live fitted results support deterministic conditional/unconditional simulation, exact response refitting, and retained- fixed-effect parametric bootstrap with a resumable private ledger. Prediction- only bundles still cannot refit, bootstrap, or run derivative inference. Satterthwaite one- and multi-DF tests are available from regular live fits and were calibrated only in the declared Gaussian random-intercept regime; boundaries and unstable derivatives return unavailable. Percentile/basic bootstrap intervals remain descriptive. Kenward–Roger adjusted covariance and scaled F tests are available for regular unit-weight fits within an explicit dense-memory ceiling; weighted and boundary cases fail closed. Named ML likelihood profiles cover SD/correlation, residual scale, and retained fixed coefficients with nuisance reoptimization and explicit endpoint status. Live fits also expose bounded postfit contrasts, tidy coefficient inference, reference grids with explicit weighting/offset semantics, and row-averaged variance decomposition. Satterthwaite and Kenward–Roger keep their own contrast-specific DF and covariance contracts. Install kamino[postfit-statsmodels] for explicit statsmodels 0.14.6 OLS/WLS and MixedLM adapters; statsmodels is not a core dependency. Robust OLS/WLS covariance uses asymptotic inference rather than inheriting residual DF. Live unit-weight Kamino fits support CR0/CR1 and fitted-target CR2 when every random grouping factor is nested in the declared independent clusters. CR2 uses contrast-specific Satterthwaite and HTZ joint inference; weighted and non-nested cluster structures fail closed. Tukey/multivariate-t adjustments and a direct marginaleffects adapter remain unsupported and fail closed or are absent. Categorical double-bar expansion, numeric random slopes across different grouping factors, transforms, and refit bundles remain unavailable. The lower-level fixed-theta array API remains available for numerical development.

The project and planned Python package are named kamino (formerly lmerx). The plan applies the production-project-template baseline and defines statistical fidelity, implementation milestones, and release evidence requirements.

For development, install the frozen environment with make setup, run the offline gate with make check, and verify the built wheel with make wheel-smoke. make supply-chain validates both distributions and emits core/all-extra CycloneDX SBOMs, checksums, and a source manifest under the ignored build/release/ directory. Docker is required only for make oracle.

Metadata

Release files for kamino-lme 0.0.1

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

Source distribution (sdist)

Source distribution for kamino-lme 0.0.1
File Size Uploaded Provenance Actions
kamino_lme-0.0.1.tar.gz 90.5 kB With provenance Details for kamino_lme-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kamino-lme 0.0.1
File Interpreter ABI Platform Actions
kamino_lme-0.0.1-py3-none-any.whl Python 3 none any Details for kamino_lme-0.0.1-py3-none-any.whl

Total release size: 188.5 kB

Release files / kamino_lme-0.0.1.tar.gz

Download URL kamino_lme-0.0.1.tar.gz
Size 90.5 kB
Tags Source
SHA-256 checksum
How to use checksums
db3aa62f09d390d18b504f49b5f55fef7d3caeda3856ab06d1fbd442ce7ac9c0
BLAKE2b-256 checksum
How to use checksums
80977401172ccc4a5787fa494338d7ed06f971db263ec8a12c5be80f7a08249c
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 Sep 17, 2026.

Transparency log

Release files / kamino_lme-0.0.1-py3-none-any.whl

Download URL kamino_lme-0.0.1-py3-none-any.whl
Size 98.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a30433087037392f8e82e3a4fc01c81ef942c0b62f69870ffae56f6120d6c4d
BLAKE2b-256 checksum
How to use checksums
c439fea711de9e5a06969b652a2b3ea587abfe9c4e8e3ec282e1aff96f3ca8c2
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 Sep 17, 2026.

Transparency log

Security for kamino-lme 0.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kamino_lme-0.0.1.tar.gz

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 Sep 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

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