Skip to main content

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.
  • Metrics to evaluate the models: predictions, clusters, size of the trees and fairness.
  • New stumps written by combining a transformer (the features) and a splitter (the split).

Installation

RuleTree requires Python 3.10 or later:

pip install RuleTree                # or, from the root of the repository: pip install .
pip install "RuleTree[shapelets]"   # optional: shapelet and partial pivot stumps (numba)
pip install "RuleTree[graphviz]"    # optional: drawing the trees (also requires the Graphviz binaries)
pip install "RuleTree[all]"         # all the optional features

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:

The HTML documentation, with the API reference, is built with Sphinx:

pip install -r requirements.txt -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.131704

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

Source distribution (sdist)

Source distribution for RuleTree 2026.10.15.131704
File Size Uploaded
ruletree-2026.10.15.131704.tar.gz 122.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for RuleTree 2026.10.15.131704
File Interpreter ABI Platform
ruletree-2026.10.15.131704-py3-none-any.whl Python 3 none any Details

Total release size: 273.7 kB

Release files / ruletree-2026.10.15.131704.tar.gz

Download URL ruletree-2026.10.15.131704.tar.gz
Size 122.9 kB
Tags Source
SHA-256 checksum
How to use checksums
97e887e8166e29869289473c9889736e308f8992792bb41fca0ae3be29b641a0
BLAKE2b-256 checksum
How to use checksums
37b4ed17e69b5f010f92a4fd037b483330ee70aceb4349b8ada692772d2fbb92
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.131704-py3-none-any.whl

Download URL ruletree-2026.10.15.131704-py3-none-any.whl
Size 150.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d7f6cc1daf4d06c085c9ef39e40e5ce32a08f9a0421015c065117409cbdd1d7
BLAKE2b-256 checksum
How to use checksums
406c6682767dc18408e0337f961c5d89a4139224cd794c3cc2f1f419de729586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

2026.10.15.131704 This release

2 release files

0.0.4

1 release file

0.0.3

1 release file

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