feature and feature interaction analyzer for gradient boosting
Project description
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
treemindis 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, andperpetual. 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 Importance
result1_d.importance()
| feature_0 | importance |
|----------------------|------------|
| worst_concave_points | 2.326004 |
| worst_perimeter | 2.245493 |
importance_plot(result1_d)
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)
Interaction Plots
interaction_plot(result2_d, (21, 22))
interaction_scatter_plot(X, result2_d, (21, 22))
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treemind-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: treemind-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06c3d2ffee141df9e15451659833b3de7da24708875ece63cbbddf0d82ba1c41
|
|
| MD5 |
377168487bbd71b4dcfd996183909921
|
|
| BLAKE2b-256 |
0083223b65d1b066401bc126d0446f80ec81e0bb79917d0ccec6669b84db1a12
|
File details
Details for the file treemind-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b55d9918a1d7de52f035a4e1a6afc94c51a2a2b3f4e073a3b8fcca365d10bb9c
|
|
| MD5 |
6284957b094eb7f21812d6d17b625a2c
|
|
| BLAKE2b-256 |
ab0403fcb463631612aab20c8918185abbc74e8c5929da331990d4287ea0c41a
|
File details
Details for the file treemind-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ee6cff65088b6ea7104f328385150ffc94d7b8bf85e05e7cf95d2937411be9e
|
|
| MD5 |
aeee241c98d4c940aa1fd87170fdbd86
|
|
| BLAKE2b-256 |
09fed12a1984d55881504d610855b23619ba6b57b5cd40d144589407b54112de
|
File details
Details for the file treemind-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: treemind-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59d21eb9170dbb81f1e517fd2c864d1a082bdff1c489e27e33184099cfc7a408
|
|
| MD5 |
1cb07338a4dba2570735fa8705d1b95e
|
|
| BLAKE2b-256 |
330c643c83bc3ee033141c9af0c3aef29a0bd7f3c92e00fb2c06bd4194539f1d
|
File details
Details for the file treemind-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b8754c653891739ea0ef01824cc22b4e3c957db3feb843bcc65c9779ab146e9
|
|
| MD5 |
5bb81bcd3eb8c4f1ddeb85ae789d2ea5
|
|
| BLAKE2b-256 |
f81c21a8f3c21d18eba9dae7e9e5fff208692e7e3151efa3bb884ea65f3cd4e9
|
File details
Details for the file treemind-0.2.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: treemind-0.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc08fff29ef54feb4b85d26a93f32f922320fc2ee7c02c3dfffc409f091fe8f2
|
|
| MD5 |
a82637452dbd2bd46c1e1413ec5d2361
|
|
| BLAKE2b-256 |
688351254f6acd8f1909b55dc7dcb1ecc1e389ac0bd1e358bf8990c4853a4998
|
File details
Details for the file treemind-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 8.4 MB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f20e50c69d4f8aaac8d7053f8011bd25a6de1b277ad157e5b5608b43d0a6c72
|
|
| MD5 |
f6d12aec5ba867f222e63e12ac18de99
|
|
| BLAKE2b-256 |
5f589a75c4863474e0534ad9553c2b9c8ffa77c0f0960751c3b7fdd25b999d81
|
File details
Details for the file treemind-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97f369fc737d56bd338f8d95fe4007abab518611e7ec256f8cfdf73e76db35a2
|
|
| MD5 |
8fed203231f935537135cbb9c7995516
|
|
| BLAKE2b-256 |
4bcf61f3e37488ea7d4a21171085096939b1c410f895c96fd6a91ded6983ebab
|
File details
Details for the file treemind-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: treemind-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d3286c94e2068bc767539e3e3384dc2c8b8b0c45fcb55c06598da5357f3a978
|
|
| MD5 |
6d6fdf4f74a03865307f85de05764d18
|
|
| BLAKE2b-256 |
12f649a11992c5d39af402587c63ea8ecfc283692c24348b40a4e1c93b692cb7
|
File details
Details for the file treemind-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b69c4beca1ff73ebcd38aefd43317e2c21a2d83ba6d0c2d0a04a6e133801d042
|
|
| MD5 |
204d726f7165587c9c01930ebcf049b1
|
|
| BLAKE2b-256 |
5acf8ac26ba43f55df302c8cb8dfa92bcdb1bcafbeb8ce1f4fad771d1fb3fc82
|
File details
Details for the file treemind-0.2.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: treemind-0.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1dfa7fe8c748bcd0dd87ecd5c5b48c8b9cb27164eb92eb82a6dbcaee4c0fe04
|
|
| MD5 |
2dd3498b6b76e52ff76cc80ae61978a4
|
|
| BLAKE2b-256 |
bfb39b1a55ff8c50431e37d0556a55acc9a1f6f75497f98c365c4c30ad0297a6
|
File details
Details for the file treemind-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6a2ab3354db7190897f428347dbdd0f5ab2609ea3dc8139c92d10ed48a7726d
|
|
| MD5 |
a2f5a3ba01375a40e763f927dc66e0da
|
|
| BLAKE2b-256 |
be329d7265c83afb60e78f2960ad7deb81a3767038cd9e2a057fe5f12d8e84f9
|
File details
Details for the file treemind-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0df723d17372c58f04deabe07989ee7ca2020a8046047e4d545cde0d7cdec327
|
|
| MD5 |
3cdedc39aa2cdc1601ba50e4d70cafbf
|
|
| BLAKE2b-256 |
aa3b79976bf8695e10f0a287007d8b116ba3442c11ae34a5a8836894f6437c46
|
File details
Details for the file treemind-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: treemind-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d062e3e6369ac08c93ce9b4d2673a49cd51977ac6805692cc75ef9d918f66631
|
|
| MD5 |
7d068489ea0a664660f9ce0788670d64
|
|
| BLAKE2b-256 |
43b78eb4f1f026c77376fa0980f2352d2a691cb9de971b7183344d0f383fc6a6
|
File details
Details for the file treemind-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a230de352bd2e4d6a3c2a248d7f34e0ba15fdcaabd5d6444400399e39f88eaec
|
|
| MD5 |
d05a1503dad878698ed3bff3fd0a9446
|
|
| BLAKE2b-256 |
1a7f5ba1a1cee784d914e6c54e9d7ae48daf5d9b95f0b82ff0c3b30a2b5ff473
|
File details
Details for the file treemind-0.2.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: treemind-0.2.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f35b4e72daf9afba7b034ae1ab95bc94c48dd1e2eb2bbdeb88bce85978a302bc
|
|
| MD5 |
e5579c04ac44114a1bd8a86a37f77181
|
|
| BLAKE2b-256 |
64f3f359c6b230f687785f0c3b0478534535700941f0fecfa3079b47c9be1fb4
|
File details
Details for the file treemind-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp39-cp39-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.9, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
315da18696bc35ab8d63d90a4ae5fbb38bd4fca0a5e3461b63860f2412b5b3e3
|
|
| MD5 |
d7379ad043d5552db931e7c4e2e61e9e
|
|
| BLAKE2b-256 |
c8bd85dec089653d138820c1d0ccaaaf718abdf0da598e64ecc9bc46bd7fe62f
|
File details
Details for the file treemind-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1420f74ed7ed2bc46aedaca1388dfbd9533baf2b4411f851ff1305dc9c659653
|
|
| MD5 |
9e0149eb11ba8aafae259a4f416f0b0e
|
|
| BLAKE2b-256 |
7b0cd9751984d3838d92f069b40bc646761e68533cef9fc4db76079f8cdf52d7
|
File details
Details for the file treemind-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: treemind-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4be7c8efc0c0583ec6a7641443a1da09e5db23badf57cf4f63e0091921267d
|
|
| MD5 |
8f648f8d6d75b6b387bf1b7478652a82
|
|
| BLAKE2b-256 |
d401d96c002ab6b409285837589ffb0a7259f4aed743d71d414810a36c3a2d39
|
File details
Details for the file treemind-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: treemind-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b16165b202fa949871f90eb14ecfc8adca14beeadb5661640f2f9b5f074664
|
|
| MD5 |
3f268007e7b6b0233436f2846ba605d0
|
|
| BLAKE2b-256 |
3d58953782ed40b4efe508f0674e8eb14c959fe41f3ea923867a3d99ea428c9c
|