Skip to main content

RuleTree

Interpretable decision trees whose nodes can be split in different ways (a threshold on a feature, the distance from an example, the distance of a time series from a pattern, ...), on tabular data, time series and images. Documentation: https://fismimosa.github.io/RuleTree/

  • Classification, regression (also with several targets) 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 drawings (matplotlib or Graphviz), 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, proximity and partial pivot stumps (numba)
pip install "RuleTree[plot]"        # optional: drawing the trees with matplotlib (plot_tree)
pip install "RuleTree[graphviz]"    # optional: Graphviz drawings (also requires the Graphviz binaries)
pip install "RuleTree[all]"         # all the optional features above
pip install "RuleTree[embeddings]"  # optional: images and texts as vectors for the pivot stumps (PyTorch)

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

The figures of the guides (docs/_static/figures, each in a light and a dark version) are drawn from fitted models by python docs/make_figures.py (it needs matplotlib): run it again when a change affects them.

More examples are in the notebooks of Examples, which the HTML documentation runs again at every build. To cite RuleTree, see docs/citing.rst.

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.11.3.220718

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.11.3.220718
File Size Uploaded Provenance Actions
ruletree-2026.11.3.220718.tar.gz 188.4 kB Without provenance Details for ruletree-2026.11.3.220718.tar.gz

Built distribution (wheel)

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

Total release size: 413.5 kB

Release files / ruletree-2026.11.3.220718.tar.gz

Download URL ruletree-2026.11.3.220718.tar.gz
Size 188.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0db4fad65eb4fd30f1a8ff0d659f558be49dd0fdc29abbaeeb0c217b6a121b5e
BLAKE2b-256 checksum
How to use checksums
f0d13d291ae45991616645f5991b41779ad78a1ee614ac9d5c49950534364fc8
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.11.3.220718-py3-none-any.whl

Download URL ruletree-2026.11.3.220718-py3-none-any.whl
Size 225.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc8abb4d49de21f19f608da98cefbcf395bdd6a5d44e3d192e8967a2a62061d0
BLAKE2b-256 checksum
How to use checksums
917e162f9bee2f5523a316f3847ca30b4e0ce165f94487dd6b8a4a0e8ac10924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for RuleTree 2026.11.3.220718

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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
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