RuleTree
RuleTree builds interpretable decision trees one node at a time. Each node is split by a stump: a threshold on a feature, the distance from an instance of the training set (a pivot), the distance of a time series from a shapelet, a fair split, ... The same tree can mix different kinds of stumps and different types of data (tabular data, time series, images), and its rules can be read, drawn and saved.
- Classification, regression and clustering trees with the scikit-learn API.
- Stumps for tabular data, time series and images, usable together in the same tree.
- Rules as text or Graphviz drawings, feature contributions of each prediction.
- Trees saved to and loaded from JSON, grown further with
partial_fit. - Gradient boosting, XGBoost and explainable boosting machines of RuleTrees.
- New stumps written by combining a transformer (the features) and a splitter (the split).
Installation
RuleTree requires Python 3.10 or later. From the root of the repository:
pip install .
pip install ".[graphviz]" # optional: drawing the trees (also requires the Graphviz binaries)
Example
from sklearn.datasets import load_iris
from RuleTree import RuleTreeClassifier
X, y = load_iris(return_X_y=True)
model = RuleTreeClassifier(max_depth=2, random_state=0).fit(X, y)
model.print_rules(model.get_rules(columns_names=["sepal length", "sepal width",
"petal length", "petal width"]))
|--- petal width <= 0.8
| output: 0
|--- petal width > 0.8
| |--- petal width <= 1.75
| | output: 1
| |--- petal width > 1.75
| | output: 2
Trees with other stumps and other types of data:
from RuleTree.stumps.classification import DecisionTreeStumpClassifier, ShapeletTreeStumpClassifier
# X: tabular data, X_ts: time series of shape (n_samples, n_signals, length)
model = RuleTreeClassifier(max_depth=3, stump_selection="best",
base_stumps=[DecisionTreeStumpClassifier(), ShapeletTreeStumpClassifier()])
model.fit(X=X, X_ts=X_ts, y=y)
Documentation
The user guide is in docs/guides:
- Getting started: classification, regression, clustering.
- Stumps: the available stumps and how to combine them.
- Tabular data, time series and images.
- Reading the tree: rules, drawings, nodes, feature contributions.
- Saving, growing and updating trees.
- Ensembles: boosting of RuleTrees.
- Extending the library: writing new stumps, transformers and splitters.
The HTML documentation, with the API reference, is built with Sphinx:
pip install -r requirements.docs.txt
make -C docs html # docs/_build/html/index.html
More examples are in the notebooks of Examples.
Tests
pip install ".[test]"
pytest
The tests include the docstring examples and the code of the guides, whose printed output is compared with the one in the guides.
Metadata
Release files for RuleTree 2026.10.15.12933
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ruletree-2026.10.15.12933.tar.gz | 191.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ruletree-2026.10.15.12933-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 460.0 kB
Release files / ruletree-2026.10.15.12933.tar.gz
| Download URL | ruletree-2026.10.15.12933.tar.gz |
|---|---|
| Size | 191.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c013f05ac4348a9a9c448559bac217f46f3b15765da0376f03da8db7737db021
|
|
BLAKE2b-256 checksum How to use checksums |
7f1d64e20f905a077fdcc75ddfa13166c8c5b77b4f0367c9052610f3a2dfeb14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / ruletree-2026.10.15.12933-py3-none-any.whl
| Download URL | ruletree-2026.10.15.12933-py3-none-any.whl |
|---|---|
| Size | 269.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae231b845e3ebaf2a745c439b71d4f40e035c3e93dee8324ec302cc9ab2f42ed
|
|
BLAKE2b-256 checksum How to use checksums |
f994f8d46534d3f3339e48a0ff9c2f756d0094517de112f814050ad7805c1cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|