Registry / ai-ml / treeinterpreter

treeinterpreter

JSON →
library0.2.3pypypi✓ verified 84d ago

A library for interpreting scikit-learn's decision tree and random forest predictions by decomposing predictions into feature contributions. Current version 0.2.3, last updated in 2019 (maintenance mode).

pip install treeinterpreter
INSTALL
IMPORT
SIG · TREEINTERPRETER
T
treeinterpreter
ai-mlpythonv0.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

treeinterpreter
✓ import treeinterpreter
✗ from treeinterpreter import treeinterpreter as ti

Train a random forest on Boston housing data and interpret a single prediction.

from sklearn.ensemble import RandomForestRegressor from sklearn.datasets import load_boston from treeinterpreter import treeinterpreter as ti boston = load_boston() X, y = boston.data, boston.target rf = RandomForestRegressor() rf.fit(X, y) prediction, bias, contributions = ti.predict(rf, X[:1]) print('Prediction:', prediction) print('Bias:', bias) print('Feature contributions:', contributions)
Debug
Known issues
deprecatedThe library is unmaintained since 2019 and may not work with recent scikit-learn versions (e.g., >0.24). Expect compatibility issues.
fix
Consider alternatives like shap or interpretml for newer scikit-learn.
affects: >=0.2.3
gotchaDuplicate naming: the module 'treeinterpreter' contains a function also named 'treeinterpreter'. Use 'from treeinterpreter import treeinterpreter as ti' to avoid confusion.
fix
Import with alias as shown.
affects: all
breakingScikit-learn v0.24+ deprecated certain internal APIs used by treeinterpreter, causing AttributeError: 'ForestClassifier' object has no attribute 'estimators_' (in some contexts).
fix
Downgrade scikit-learn to <=0.23 or patch the library. Use shap as alternative.
affects: scikit-learn >=0.24
gotchaThe library only supports tree-based models from scikit-learn (RandomForest, ExtraTrees, DecisionTree). Does not work with other models.
fix
Ensure your model is a tree-based ensemble.
affects: all
Upgrade
Version history
0.2.3latest on PyPI · released Jan 10, 2021
Audit
Dependencies
scikit-learnrequiredRequired for model objects
numpyrequiredRequired for array operations
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
treeinterpreter — pip install treeinterpreter · libregistry