Open source Python package

mixle

AI for real data. No cleaning required.

Declare the shape of your data once: records, mixtures, sequences, HMMs, and enumerated outcomes. Fit that structure, then use the fitted object to score, sample, inspect, and save.

pip install mixle

Core idea

One model object should do the work.

In many projects the modeling code, scoring code, sampler, serializer, and inspection tools drift apart. mixle keeps those operations attached to the fitted distribution.

Fit Use direct estimates, EM, MAP, conjugate updates, or registered routes from the declared model shape.
Use Call density, sampling, encoding, enumeration, explanation, and persistence on the fitted object.
Extend Keep task models, companion packages, and specialized solvers outside the core until you need them.

Structured latent model

from mixle.inference import *
from mixle.models import *
from mixle.stats import *

# records is a list of sessions.
# each observation is (tone, token_pair, event_name)
# token_pair is (context_token_ids, next_token_id)
# records[:1] == [[
#     (-1.64, ([0, 1, 2, 3], 1), "browse"),
#     (0.82, ([4, 5, 6, 7], 7), "checkout"),
# ]]

model = optimize(
    records,
        HiddenMarkovEstimator([
            CompositeEstimator((
                MixtureEstimator([
                    GaussianEstimator(),
                    GaussianEstimator(),
                ]),
                TransformerLMEstimator(vocab=8),
                CategoricalEstimator(),
            ))
    ] * 2),
)

model.log_density(records[0])

Scope

Use it when structure matters.

mixle is useful when flattening everything into one matrix would hide the object you actually want to model.

Read the concept guide

Good fit

  • Mixed records with numeric, categorical, sequence, set, tree, or missing fields.
  • Mixtures, HMMs, grammars, Bayesian leaves, or tied parameters in one model.
  • Discrete models where top-k, rank, seek, or support enumeration matter.
  • Local task models distilled from LLM, human, or rule-based teachers.

Usually not first choice

  • Plain single-table supervised learning already covered by scikit-learn.
  • Pure large-scale tensor training where PyTorch or JAX is the whole abstraction.
  • One-off scripts where a few SciPy calls are clearer than a model object.

Project

Source, issues, and release history.

mixle is published under the MIT License. Use GitHub for source, issues, examples, tests, and contribution discussion.