WoodTapper: a Python package for explaining decision tree ensembles
- Authors
- Abdoulaye Sakho
- J.Aouad
- Emmanuel Malherbe
- Carl-Erik Gauthier
- Erwan Scornet
- Affiliations
- Artefact Research Center
- LPSM, Sorbonne Université and Université Paris Cité
- Société Générale
- Accepted at
- Journal of Open Source Software 2026
- Date
Abstract
WoodTapper provides a dedicated Python toolbox to inspect, decompose, and explain predictions from tree-based classifiers using methods that directly leverage the discrete structure of trees. More specifically, one module converts any tree-based model of scikit-learn into a rule-based method, and a second module provides example-based explanations for a given input sample.
Cite this paper
@article{sakho2026woodtapper,
title = {WoodTapper: a Python package for explaining decision tree ensembles},
author = {Abdoulaye Sakho and J.Aouad and Emmanuel Malherbe and Carl-Erik Gauthier and Erwan Scornet},
journal = {Journal of Open Source Software},
year = {2026},
doi = {10.21105/joss.10112},
url = {https://doi.org/10.21105/joss.10112}
}Copied
Summary
WoodTapper provides a dedicated Python toolbox to inspect, decompose, and explain predictions from tree-based classifiers using methods that directly leverage the discrete structure of trees. More specifically, one module converts any tree-based model of scikit-learn into a rule-based method, and a second module provides example-based explanations for a given input sample.
Statement of need
Interpretable machine learning has become an increasingly critical concern [14, 18] as predictive models are deployed in high-stakes settings such as healthcare [11], marketing [13] or finance [9, 17] which is moreover a regulated sector. While complex models, such as tree-based ensemble methods, often yield strong predictive performance, their opacity can pose challenges for accountability, trust and compliance. Popular explanation toolkits such as SHAP [12] and LIME [16] offer model-agnostic or surrogate-based attributions that are broadly applicable, but they can be computationally expensive for large ensembles, and their computation remains a black-box estimation. Another field of interpretable models are rule-based methods. They are especially attractive because they are in the form of "if-then" statements, which are often easier to audit and communicate than latent feature transformations.
State of the Field
The original SIRUS algorithm [3, 2] offered a principled approach to generate simple and stable rule-based models from random forests. However, its implementations have been limited to R and Julia [3, 10], creating accessibility barriers for the Python data science community. WoodTapper addresses this gap by offering a native Python implementation that integrates with the scikit-learn ecosystem. Furthermore, WoodTapper extends rules extraction from all the tree-based models in scikit-learn (Random Forest [4], Gradient Boosting [6] and Extremely Randomized Trees [7]) and to the multiclass classification setting.
In addition, WoodTapper introduces an example-based explainability methodology that can be applied to all scikit-learn tree-based models. This approach associates predicted samples with representative samples from the training data set, explaining tree-based models' predictions through examples.
We compare below our Python implementation WoodTapper with the Julia, R and skgrf versions (see Tables 1 and 3) and observe that WoodTapper provides broader options for tree-based model extraction, faster rule-extraction runtimes, and support for multiclass classification with unlimited tree depth.
Research impact statement
As a Python package, WoodTapper provides a practical interface for extracting decision rules with SIRUS and integrating those rules into downstream projects. The SIRUS rule-extraction procedure, originally developed for random forests, has been applied in more than 200 publications (according to Google Scholar 2025) and has since been extended to diverse domains, including microbiome analysis, time-series analysis, and hydrological process analysis. Python adaptation of SIRUS has been requested multiple times by practitioners and researchers to the authors, which WoodTapper addresses. Beyond rule extraction, WoodTapper offers an example-based auditing tool for black-box, tree-based models deployed in production, and has been already applied successfully in the context of Artefact’s consulting missions with clients of different sectors, including banking.
WoodTapper has demonstrated notable research impact and has grown its user and contributor communities since its initial release. It has been downloaded more than 1,500 times, indicating strong demand for a Python implementation. The package has evolved through contributions from multiple developers, with community members able to add new features, report and fix bugs, and propose enhancements. Furthermore, the fully reproducible benchmarks described below show concrete improvements in both generalisation to all tree-based models and computation time.
Software design
WoodTapper package adheres to the scikit-learn [15] estimator interface. This design enables smooth integration with existing workflows involving pipelines, cross-validation, and model selection, and enables to efficiently benefit from future maintenance updates and improvements to scikit-learn. The implementation leverages NumPy [8] for numerical computation and joblib for parallel processing to optimize performance on large datasets (1). The code architecture uses a Mixin inherited by all tree-based models to improve code reuse and factorization. For each tree-based ensemble type, a subclass inherits both the original scikit-learn class and the Mixin. The standard fit and predict methods remain unchanged, while additional methods of WoodTapper are available.
Rules Extraction Module
Formulation
In this section, we present our RulesExtraction module and we specifically consider its application to a random forest classifier, which corresponds to the SIRUS algorithm introduced by [3]. The module is designed to extract a set of rules from an ensemble of trees and then aggregate them to produce the final output probabilities.
We suppose that we have a training set composed of pairs taking values in and respectively (binary classification). We denote by the -th component of the -th sample in . We suppose we have a set of trees from a tree ensemble procedure, each grown with randomness .
In a tree , we denote by a path of successive splits from the root node. defines thus a hyperrectangle in the input space, . We associate with a rule function returning the mean of from the training sample inside and outside .
For a set of trees and a path , we define:
which corresponds to the empirical probability that the path belongs to the set of trees . The set of final rules is where with . The final rules are aggregated as follows for building the final estimator:
Beyond the binary classification detailed here, we also implemented the rule extractor for regression, where final rules are aggregated using weights learned via ridge regression.
Running time
We compare the runtimes of SIRUS in Python (ours), R, and Julia using 5 threads on an AMD Ryzen Threadripper PRO 5955WX (16 cores, 4GHz) with 256GB RAM. We also experimented on large-scale industrial data sets, including from the banking sector, and observed the same trends as displayed here. SIRUS.jl exhibits higher runtime compared to Python and R implementations.
The R version, relying on ranger, is faster for tree construction on large datasets than scikit-learn. Our Python implementation, however, is considerably more efficient for rule extraction, regardless of sample size or feature dimensionality (see Figures 1 and 2).
Extracted rules and predictive performances
The rules generated by the original SIRUS (R) and our RulesExtraction implementation (Figures 3 and 4) on the Titanic dataset match for 9 out of 10 rules. The predictive performances reported in Table 2 are also very similar, confirming that our implementation faithfully reproduces the original algorithm. The remaining differences stem from the fact that the Python and R implementations do not use the exact same randomness when growing trees. As a result, rule occurrence frequencies can vary, which may change the ordering of the rules (Figures 3 and 4) and, in turn, affect the final rule selected (therefore, the predictive performance is not exactly identical).


Example-based explainability module
Formulation
The ExampleExplanation module of WoodTapper is independent of the RulesExtraction module and provides an example-based explainability. It enables tree-based models to identify the most similar training samples to , using the similarity measure induced by generalized random forests [4, 1]. For a new sample with unknown label and a decision tree T, let L() denote the set of training samples that share the same leaf as . We define the similarity (, ) between and as:
Finally, the training samples with the highest values, along with their target values , are shown as the examples that best explain the prediction of by the tree-based ensemble model.
In Python, the skgrf [5] package is an interface for using the R implementation of generalized random forest, focusing on classifiers for specific learning tasks (causal inference, quantile regression,...). For each task, the user can compute the kernel weights, equivalent to our leaf frequency match introduced above. Thus, we compare the kernel weights computation by skgrf and our module. We stress the fact that our ExampleExplanation is designed for usual tree-based models such as random forests or extra trees and not specifically in a context of causal inference or quantile regression. In particular, the tree building of our forest is different from the one in skgrf.
Running time
In figure 5, we compare the kernel weight computation runtime of ExampleExplanation and skgrf [5] using the same hardware as previous experiments. ExampleExplanation is consistently faster.
Next step
A problem worth researching?
Tell us what you are trying to solve, and we will put you in touch with the people who work on it.