Skip to main content

treemind

treemind is a high-performance library for interpreting tree-based models. It supports regression, binary and multiclass classification, and handles both numerical and categorical features. By analyzing split intervals and feature interactions, treemind helps you understand which features drive predictions and how they interact making it ideal for model explanation, debugging, and auditing.

A formal research paper detailing the theoretical foundation of treemind is forthcoming.


Installation

Install treemind via pip:

pip install treemind

Key Features

  • Feature Analysis Quantifies how individual features influence predictions across specific decision boundaries.

  • Interaction Detection Detects and visualizes interaction effects between two or more features at any order n, constrained by memory and time.

  • Optimized Performance Fast even on deep models thanks to efficient Cython-backed core.

  • Rich Visualizations Interactive and static plots to visualize importance, split intervals, and interaction strength.

  • Broad Model Support Compatible with xgboost, lightgbm, catboost, sklearn, and perpetual. Works with regression, binary, and multiclass tasks. Supports categorical features.


Algorithm & Performance

The treemind algorithm analyzes how often features and their combinations appear in decision paths, then summarizes their behavior over split intervals.


Quickstart Example

This walkthrough shows how to use treemind.Explainer with a LightGBM model trained on the Breast Cancer dataset.

from lightgbm import LGBMClassifier
from sklearn.datasets import load_breast_cancer

from treemind import Explainer
from treemind.plot import (
    feature_plot,
    interaction_plot,
    interaction_scatter_plot,
    importance_plot,
)

# Load sample data
X, y = load_breast_cancer(return_X_y=True, as_frame=True)

# Train a model
model = LGBMClassifier(verbose=-1)
model.fit(X, y)

# Create an explainer
explainer = Explainer(model)

Count Feature Appearances

To see how often each feature (or feature pair) appears in the decision trees:

explainer.count_node(degree=1)  # Individual feature usage
| column_index | count |
|--------------|-------|
| 21           | 1739  |
| 27           | 1469  |
explainer.count_node(degree=2)  # Pairwise feature usage
| column1_index | column2_index | count |
|---------------|---------------|-------|
| 21            | 22            | 927   |
| 21            | 23            | 876   |

One-Dimensional Feature Analysis

Analyze how a single feature influences the model:

result1_d = explainer.explain(degree=1)

Inspect a specific feature (e.g., feature 21):

result1_d[21]
| worst_texture_lb | worst_texture_ub | value     | std      | count  |
|------------------|------------------|-----------|----------|--------|
| -inf             | 18.460           | 3.185128  | 8.479232 | 402.24 |
| 18.460           | 19.300           | 3.160656  | 8.519873 | 402.39 |

Feature Visualization

feature_plot(result1_d, 21)

Feature Plot

Feature Importance

result1_d.importance()
| feature_0            | importance |
|----------------------|------------|
| worst_concave_points | 2.326004   |
| worst_perimeter      | 2.245493   |
importance_plot(result1_d)

Feature Importance


Two-Dimensional Interaction Analysis

Evaluate how two features interact to influence predictions:

result2_d = explainer.explain(degree=2)
result2_d[21, 22]
| worst_texture_lb | worst_texture_ub | worst_concave_points_lb | worst_concave_points_ub | value    | std      | count  |
|------------------|------------------|--------------------------|--------------------------|----------|----------|--------|
| -inf             | 18.46            | -inf                     | 0.058860                 | 4.929324 | 7.679424 | 355.40 |

Interaction Importance

result2_d.importance()
| feature_0         | feature_1            | importance |
|------------------|----------------------|------------|
| worst_perimeter  | worst_area           | 2.728454   |
| worst_texture    | worst_concave_points | 2.439605   |
importance_plot(result2_d)

2D Importance

Interaction Plots

interaction_plot(result2_d, (21, 22))

Interaction Plot

interaction_scatter_plot(X, result2_d, (21, 22))

Interaction Scatter


Contributing

Contributions are welcome! If you'd like to improve treemind or suggest new features, feel free to fork the repository and submit a pull request.


License

treemind is released under the MIT License. See the LICENSE file for details.

Metadata

Release files for treemind 0.2.0

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

Built distributions (wheels)

Table of built distributions (wheels) for treemind 0.2.0
File
treemind-0.2.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
treemind-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
treemind-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
treemind-0.2.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
treemind-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
treemind-0.2.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
treemind-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
treemind-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
treemind-0.2.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
treemind-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
treemind-0.2.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
treemind-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.2+ x86-64 Details
treemind-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
treemind-0.2.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
treemind-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
treemind-0.2.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
treemind-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl CPython 3.9 CPython 3.9 Linux musl 1.2+ x86-64 Details
treemind-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
treemind-0.2.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
treemind-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details

Total release size: 81.3 MB

Release files / treemind-0.2.0-cp312-cp312-win_amd64.whl

Download URL treemind-0.2.0-cp312-cp312-win_amd64.whl
Size 1.5 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
06c3d2ffee141df9e15451659833b3de7da24708875ece63cbbddf0d82ba1c41
BLAKE2b-256 checksum
How to use checksums
0083223b65d1b066401bc126d0446f80ec81e0bb79917d0ccec6669b84db1a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL treemind-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Size 8.3 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
b55d9918a1d7de52f035a4e1a6afc94c51a2a2b3f4e073a3b8fcca365d10bb9c
BLAKE2b-256 checksum
How to use checksums
ab0403fcb463631612aab20c8918185abbc74e8c5929da331990d4287ea0c41a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL treemind-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9ee6cff65088b6ea7104f328385150ffc94d7b8bf85e05e7cf95d2937411be9e
BLAKE2b-256 checksum
How to use checksums
09fed12a1984d55881504d610855b23619ba6b57b5cd40d144589407b54112de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL treemind-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
59d21eb9170dbb81f1e517fd2c864d1a082bdff1c489e27e33184099cfc7a408
BLAKE2b-256 checksum
How to use checksums
330c643c83bc3ee033141c9af0c3aef29a0bd7f3c92e00fb2c06bd4194539f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL treemind-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 1.6 MB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
3b8754c653891739ea0ef01824cc22b4e3c957db3feb843bcc65c9779ab146e9
BLAKE2b-256 checksum
How to use checksums
f81c21a8f3c21d18eba9dae7e9e5fff208692e7e3151efa3bb884ea65f3cd4e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp311-cp311-win_amd64.whl

Download URL treemind-0.2.0-cp311-cp311-win_amd64.whl
Size 1.5 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
cc08fff29ef54feb4b85d26a93f32f922320fc2ee7c02c3dfffc409f091fe8f2
BLAKE2b-256 checksum
How to use checksums
688351254f6acd8f1909b55dc7dcb1ecc1e389ac0bd1e358bf8990c4853a4998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL treemind-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
Size 8.4 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
0f20e50c69d4f8aaac8d7053f8011bd25a6de1b277ad157e5b5608b43d0a6c72
BLAKE2b-256 checksum
How to use checksums
5f589a75c4863474e0534ad9553c2b9c8ffa77c0f0960751c3b7fdd25b999d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL treemind-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.4 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
97f369fc737d56bd338f8d95fe4007abab518611e7ec256f8cfdf73e76db35a2
BLAKE2b-256 checksum
How to use checksums
4bcf61f3e37488ea7d4a21171085096939b1c410f895c96fd6a91ded6983ebab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL treemind-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8d3286c94e2068bc767539e3e3384dc2c8b8b0c45fcb55c06598da5357f3a978
BLAKE2b-256 checksum
How to use checksums
12f649a11992c5d39af402587c63ea8ecfc283692c24348b40a4e1c93b692cb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl

Download URL treemind-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
b69c4beca1ff73ebcd38aefd43317e2c21a2d83ba6d0c2d0a04a6e133801d042
BLAKE2b-256 checksum
How to use checksums
5acf8ac26ba43f55df302c8cb8dfa92bcdb1bcafbeb8ce1f4fad771d1fb3fc82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp310-cp310-win_amd64.whl

Download URL treemind-0.2.0-cp310-cp310-win_amd64.whl
Size 1.5 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c1dfa7fe8c748bcd0dd87ecd5c5b48c8b9cb27164eb92eb82a6dbcaee4c0fe04
BLAKE2b-256 checksum
How to use checksums
bfb39b1a55ff8c50431e37d0556a55acc9a1f6f75497f98c365c4c30ad0297a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL treemind-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl
Size 8.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
a6a2ab3354db7190897f428347dbdd0f5ab2609ea3dc8139c92d10ed48a7726d
BLAKE2b-256 checksum
How to use checksums
be329d7265c83afb60e78f2960ad7deb81a3767038cd9e2a057fe5f12d8e84f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL treemind-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0df723d17372c58f04deabe07989ee7ca2020a8046047e4d545cde0d7cdec327
BLAKE2b-256 checksum
How to use checksums
aa3b79976bf8695e10f0a287007d8b116ba3442c11ae34a5a8836894f6437c46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL treemind-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d062e3e6369ac08c93ce9b4d2673a49cd51977ac6805692cc75ef9d918f66631
BLAKE2b-256 checksum
How to use checksums
43b78eb4f1f026c77376fa0980f2352d2a691cb9de971b7183344d0f383fc6a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL treemind-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a230de352bd2e4d6a3c2a248d7f34e0ba15fdcaabd5d6444400399e39f88eaec
BLAKE2b-256 checksum
How to use checksums
1a7f5ba1a1cee784d914e6c54e9d7ae48daf5d9b95f0b82ff0c3b30a2b5ff473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp39-cp39-win_amd64.whl

Download URL treemind-0.2.0-cp39-cp39-win_amd64.whl
Size 1.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
f35b4e72daf9afba7b034ae1ab95bc94c48dd1e2eb2bbdeb88bce85978a302bc
BLAKE2b-256 checksum
How to use checksums
64f3f359c6b230f687785f0c3b0478534535700941f0fecfa3079b47c9be1fb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl

Download URL treemind-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl
Size 8.3 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
315da18696bc35ab8d63d90a4ae5fbb38bd4fca0a5e3461b63860f2412b5b3e3
BLAKE2b-256 checksum
How to use checksums
c8bd85dec089653d138820c1d0ccaaaf718abdf0da598e64ecc9bc46bd7fe62f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL treemind-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1420f74ed7ed2bc46aedaca1388dfbd9533baf2b4411f851ff1305dc9c659653
BLAKE2b-256 checksum
How to use checksums
7b0cd9751984d3838d92f069b40bc646761e68533cef9fc4db76079f8cdf52d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / treemind-0.2.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL treemind-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1b4be7c8efc0c0583ec6a7641443a1da09e5db23badf57cf4f63e0091921267d
BLAKE2b-256 checksum
How to use checksums
d401d96c002ab6b409285837589ffb0a7259f4aed743d71d414810a36c3a2d39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / treemind-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL treemind-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
b7b16165b202fa949871f90eb14ecfc8adca14beeadb5661640f2f9b5f074664
BLAKE2b-256 checksum
How to use checksums
3d58953782ed40b4efe508f0674e8eb14c959fe41f3ea923867a3d99ea428c9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.2.0 This release

20 release files

0.1.1

24 release files

0.0.1

24 release files

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