v1.2.0 · On CRAN

Ensemble power.
One tree to explain it.

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.

CRAN version CRAN downloads per month CRAN total downloads R-CMD-check status
Abstract

Ensemble accuracy. Single-tree transparency.

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.

#explainability #ensemble-trees #decision-tree #XAI #open-science
The core idea

From 500+ trees to
one decision you can explain.

Case study: Heart Disease Risk Stratification — the e2tree distils 500 ensemble trees into six clear, auditable decision rules a cardiologist can act on.

Full use cases
Interactive — e2tree distillation engine

Press Distil → then hover any leaf node to read the full decision path. The panel below will explain each rule in clinical terms.

Workflow

From raw data to interpretable rules in six steps.

Each function maps to one step. Every intermediate object is inspectable and exportable.

Full documentation
  1. 01
    Train a tree-based ensemble

    Use randomForest() or ranger(). Any standard training configuration works.

  2. 02
    Compute the dissimilarity matrix

    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.

  3. 03
    Build the explainable tree

    e2tree() grows the single tree guided by the dissimilarity structure. Depth, impurity threshold, and node size are controlled via the setting list.

  4. 04
    Inspect and visualize

    Standard S3 methods — print(), summary(), plot() — provide a compact overview, detailed decision rules, and visual rendering via rpart.plot or partykit.

  5. 05
    Predict and validate

    predict() routes new observations through the split rules. eValidation() checks how closely the tree matches the ensemble's proximity structure.

  6. 06
    Local and global importance

    vimp() computes variable importance from the tree's split structure. loi() provides observation-level local importance with optional permutation-based significance testing.

Quick start

Five lines from ensemble to tree.

Five steps from raw data to an interpretable tree. Install from CRAN and run it today.

# Install from CRAN install.packages("e2tree") library(e2tree) library(randomForest) # or ranger # 1. Train an ensemble of decision trees ensemble <- randomForest( Species ~ ., data = training, importance = TRUE, proximity = TRUE ) # 2. Compute dissimilarity from ensemble co-occurrence D <- createDisMatrix( ensemble, data = training, label = "Species", parallel = list(active = FALSE) ) # 3. Build the single explainable tree setting <- list(impTotal = 0.1, maxDec = 0.01, n = 2, level = 5) tree <- e2tree(Species ~ ., training, D, ensemble, setting) # 4. Inspect, visualize, predict print(tree) plot(tree, ensemble = ensemble) pred <- predict(tree, newdata = validation)
Capabilities

A complete suite for explainable ensemble analysis.

01

Any Tree Ensemble

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.

randomForest ranger xgboost lightgbm gbm catboost
02

Measured Fidelity, Not Assumed

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.

nLoI Cressie–Read permutation test
03

Local Explanations You Can Trust

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.

localLoI() eContribution() eNeighbors() eCounterfactual()
04

Panel Data & Interoperability

panel_e2tree() decomposes longitudinal features à la Mundlak into between- and within-unit components, explaining each. e2tree objects also convert to rpart and partykit formats.

panel_e2tree() as.rpart() as.party()
Publications

Peer-reviewed methodology.

Two peer-reviewed papers describe the method — one for classification, one for regression. A third, under review, formalises how reconstruction quality is measured.

Classification · 2024

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 ↗

Regression · 2026

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 ↗

Reconstruction quality · Under review

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.