User-friendly Python toolbox for interpreting and manipulating decision tree ensembles from scikit-learn
WoodTapper is a Python toolbox for:
- Rule extraction from tree-based ensembles.
- Example-based explanation module that links predictions to a small set of representative samples.
Woodtapper is fully compatible with scikit-learn forests and boosting models.
From PyPi:
pip install woodtapperFrom this repository, within a pip/conda/mamba environment (python=3.12): pip install -r requirements.txt pip install -e '.[dev]'
## RandomForestClassifier rules extraction
from woodtapper.extract_rules import SirusClassifier
from woodtapper.extract_rules.visualization import show_rules
sirus = SirusClassifier(n_estimators=1000,max_depth=2,
quantile=10,p0=0.01, random_state=0)
sirus.fit(X_train,y_train)
y_pred_sirus = sirus.predict(X_test)
show_rules(Sirus,max_rules=10) # Show rules## RandomForestClassifier rules extraction
from woodtapper.example_sampling import RandomForestClassifierExplained
rf_explained = RandomForestClassifierExplained(n_estimators=100)
rf_explained.fit(X_train,y_train)
X_explain, y_explain = rf_explained.explanation(X_test) # Get the 5 most similar samples for each test sampleThis work was done through a partnership between the Artefact Research Center and the Laboratoire de Probabilités Statistiques et Modélisation (LPSM) of Sorbonne University.
If you find the code useful, please consider citing us:
@misc{woodtapper,
title = {WoodTapper: a Python package for tapping decision tree ensembles},
author = {Sakho, Abdoulaye and AOUAD, Jad and Malherbe, Emmanuel and Scornet, Erwan},
year = {2025},
howpublished = {\url{https://github.com/artefactory/woodtapper}},
}For SIRUS methodology, consider citing:
@article{benard2021sirus,
title={Sirus: Stable and interpretable rule set for classification},
author={Benard, Clement and Biau, Gerard and Da Veiga, Sebastien and Scornet, Erwan},
year={2021}
}