Thanks to visit codestin.com
Credit goes to github.com

Skip to content

artefactory/woodtapper

Repository files navigation

User-friendly Python toolbox for interpreting and manipulating decision tree ensembles from scikit-learn

CI Status Linting , formatting, imports sorting: ruff Pre-commit Docs

License Python Versions PyPI Version

🪵 Key Features

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.

🛠 Installation

From PyPi:

pip install woodtapper

From this repository, within a pip/conda/mamba environment (python=3.12): pip install -r requirements.txt pip install -e '.[dev]'

🌿 WoodTapper RulesExtraction module

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

🌱 WoodTapper ExampleExplanation module

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

🙏 Acknowledgements

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

   

📜 Citation

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