e2tree distils any ensemble of decision trees into a single, interpretable tree that reproduces the ensemble's own reasoning as transparent, human-readable rules — and measures how faithfully it does so. Classification and regression, on any tree-based ensemble.
Ensemble methods based on decision trees routinely outperform single decision trees, but at the cost of interpretability: hundreds of learners whose joint reasoning is opaque to practitioners and regulators alike.
e2tree resolves this by deriving a co-occurrence matrix from the ensemble — how often any two observations share a terminal node across all trees — then using that dissimilarity structure to grow a single tree that summarises the ensemble's behaviour.
The result is a concise decision tree whose split rules, variable importances, and local explanations faithfully reproduce what the ensemble learned. That faithfulness is not assumed — it is measured, by the nLoI family of divergence statistics.
The framework supports both classification and regression, and works with any tree ensemble — randomForest, ranger, xgboost, lightgbm, gbm, catboost. Open-source on CRAN under the MIT license.
Case study: Heart Disease Risk Stratification — the e2tree distils 500 ensemble trees into six clear, auditable decision rules a cardiologist can act on.
Press Distil → then hover any leaf node to read the full decision path. The panel below will explain each rule in clinical terms.
Each function maps to one step. Every intermediate object is inspectable and exportable.
Full documentationUse randomForest() or ranger(). Any standard training configuration works.
createDisMatrix() derives a co-occurrence matrix O from the ensemble's terminal node structure. Each entry oij ∈ [0,1] measures how often observations i and j share a leaf across all trees. The dissimilarity is D = 1 − O.
e2tree() grows the single tree guided by the dissimilarity structure. Depth, impurity threshold, and node size are controlled via the setting list.
Standard S3 methods — print(), summary(), plot() — provide a compact overview, detailed decision rules, and visual rendering via rpart.plot or partykit.
predict() routes new observations through the split rules. eValidation() checks how closely the tree matches the ensemble's proximity structure.
vimp() computes variable importance from the tree's split structure. loi() provides observation-level local importance with optional permutation-based significance testing.
Five steps from raw data to an interpretable tree. Install from CRAN and run it today.
Bagging or boosting, classification or regression. A three-method adapter layer isolates the backend, so the algorithm never changes — and dissimilarity matrices are tagged with the model that produced them.
The nLoI quantifies agreement between the ensemble's proximity structure and the tree's — and decomposes into within- and between-node parts, so you learn where reconstruction fails. Alongside Hellinger, wRMSE, RV and SSIM, under one permutation framework.
explain() composes the whole per-instance layer: additive attribution, nearest cases by the ensemble's own proximity, region fidelity via localLoI(), plus verified counterfactuals and bootstrap stability.
panel_e2tree() decomposes longitudinal features à la Mundlak into between- and within-unit components, explaining each. e2tree objects also convert to rpart and partykit formats.
Two peer-reviewed papers describe the method — one for classification, one for regression. A third, under review, formalises how reconstruction quality is measured.
Aria, M., Gnasso, A., Iorio, C., & Pandolfo, G. (2024). Explainable ensemble trees. Computational Statistics, 39(1), 3–19. doi:10.1007/s00180-022-01312-6 ↗
Aria, M., Gnasso, A., Iorio, C., & Fokkema, M. (2026). Extending Explainable Ensemble Trees to Regression Contexts. Applied Stochastic Models in Business and Industry, 42(1), e70064. doi:10.1002/asmb.70064 ↗
Aria, M., Gnasso, A., & Iorio, C. A Family of Divergence Measures for Evaluating the Reconstruction Quality of Explainable Ensemble Trees. Submitted to Computational Statistics & Data Analysis.