Installation¶
mltreelib is a Python package with a Rust core — one wheel; pulls pyarrow>=14
(required runtime dependency).
From PyPI¶
With uv¶
From source¶
Building from source needs a Rust toolchain (rustup) and maturin:
git clone https://github.com/jkapila/mltreelib
cd mltreelib
uv run maturin develop --release # builds the Rust core into your environment with release optimizations
Verify the install¶
An unfitted tree refuses to print its structure (by design); the call should
raise ValueError: ModelTree is not fitted. Fit anything and print(model)
shows the rpart-style tree.
Plotting (optional extra)¶
Charts and diagrams ride on the standard rendering wheels — install them only when you build figures:
mltreelib.plots (metric charts) and ModelTree.to_dot() + pygraphviz
(tree diagrams) are the two consumers. The core library never imports them.
What you get¶
ModelTree |
the tree: fit / predict, rpart-style text, SVG diagram, constraints |
| 14 encoders | OneHot, Hashing, Target, CatBoost, WoE, James-Stein, Count, Leave-One-Out, M-Estimator, Base-N, Sum, Quantile, TF-IDF, Embedding |
| scalers & builders | VariableScaler, GroupedScaler, DatasetBuilder, IndexMapper |
Metrics |
regression / classification / regression-by-group reports |
| dataset helpers | list_datasets, load_dataset, summarize, generate, calendar / lag / window transforms |
Numerics run in the Rust core; the data layer is the same code the benchmarks run on.