Skip to main content

A Python toolbox for interpretable and explainable tree ensembles.

Project description

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 that provides:

  • Rule extraction from tree-based ensembles: Generates a final estimator composed of a sequence of simple rule-based on features and thresholds.

  • Example-based explanations: Connects predictions to a small set of representative samples, returning the most similar examples along with their target values.

Detailed information about the modules can be found here.

WoodTapper is fully compatible with scikit-learn tree ensemble models.

🛠 Installation

From PyPi:

pip install woodtapper

From this repository, within a pip/conda/mamba environment (python=3.12):

pip install -e .[dev,docs]

🌿 WoodTapper RulesExtraction module

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

from woodtapper.example_sampling import RandomForestClassifierExplained

rf_explained = RandomForestClassifierExplained(n_estimators=100)
rf_explained.fit(X_train,y_train)
Xy_explain = rf_explained.explanation(X_test) # Get the 5 most similar samples (and target) 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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

woodtapper-0.0.12.tar.gz (367.4 kB view details)

Uploaded Source

File details

Details for the file woodtapper-0.0.12.tar.gz.

File metadata

  • Download URL: woodtapper-0.0.12.tar.gz
  • Upload date:
  • Size: 367.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for woodtapper-0.0.12.tar.gz
Algorithm Hash digest
SHA256 b4fbe62e1dfe8c9b5dc1da8982651c661f571d3131e0cdd087d86136ba7de5a8
MD5 41068645dd7e707606572f2b7b5b0383
BLAKE2b-256 38f891067f51d6379997336181abe95b04ab1857385c899bf59e98c8a58f2b1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page