Use cases · e2tree in practice

When accuracy alone
is not enough.

Ensemble models are often accurate enough to deploy but too opaque to act on. Three case studies — medical, financial, industrial — where that gap had real consequences.

Case I · Medical

Heart disease risk stratification —
a rule a cardiologist can act on.

A hospital's cardiology department uses an ensemble of decision trees trained on the Heart Disease UCI dataset to screen patients. The model achieves 88% AUC — impressive, but clinically unusable as a black box. Physicians cannot validate, challenge, or communicate a prediction without understanding its basis.

e2tree distils the ensemble's reasoning into a five-leaf decision tree with four interpretable split rules. The tree preserves 91% of the ensemble's proximity structure (measured by eValidation()) while reducing the model to something a cardiologist can recite from memory.

Dataset at a glance
303
Patients
13
Clinical features
88%
Ensemble AUC
5
e2tree leaves
binary classification clinical XAI UCI Heart Disease
Step-by-step

From ensemble
to clinical rule.

Follow the six steps below, then explore the resulting tree in the interactive panel on the right.

01

Train the ensemble

500 trees on 75% of the Heart Disease dataset. proximity=TRUE stores co-occurrence for later use.

02

Compute the dissimilarity matrix

createDisMatrix() builds the n×n matrix D from terminal-node co-occurrence across all 500 trees. Each entry encodes how often two patients share a leaf.

03

Fit e2tree

One call to e2tree() with depth ≤ 4 and min-node 5. The algorithm selects only the splits that best reconstruct D.

04

Validate fidelity

eValidation() confirms the tree reproduces 91% of the ensemble's proximity structure — a high concordance score.

05

Read the tree

Each path from root to leaf is a complete clinical rule. Click any leaf in the explorer to read it in plain language.

06

Extract local importance

loi() shows which features drove the classification for each individual patient — essential for clinical audit trails.

library(e2tree) library(randomForest) # 1 — Train the ensemble set.seed(42) ensemble <- randomForest( target ~ ., data = heart_train, ntree = 500, importance = TRUE, proximity = TRUE ) # 2 — Compute co-occurrence dissimilarity matrix D <- createDisMatrix( ensemble, data = heart_train, label = "target", parallel = list(active = FALSE) ) # 3 — Fit e2tree (depth ≤ 4, min 5 obs per node) setting <- list( impTotal = 0.08, maxDec = 0.01, n = 5, level = 4 ) tree <- e2tree(target ~ ., heart_train, D, ensemble, setting) # 4 — Validate structural fidelity vs. ensemble ev <- eValidation(tree, D, ensemble) measures(ev) # concordance ≈ 0.91 # 5 — Visualize decision rules plot(tree, ensemble = ensemble) # 6 — Local importance (per patient) local_imp <- loi(tree, ensemble, heart_train, "target") plot(local_imp)
Interactive explorer

Read every
decision path.

Click a leaf node or a patient profile below. The full path from root to leaf will animate, and the panel will explain each split in clinical language.

Patient profiles
YES NO YES NO YES NO YES NO YES NO Chest Pain Type ≤ 2 Thalassemia ≤ 2 Age ≤ 54 Major Vessels ≤ 0 Cholesterol ≤ 220 mg/dL ♥ Low Risk 87% · n=41 ♥ Low Risk 79% · n=36 ♥ Low Risk 73% · n=18 ⚠ High Risk 81% · n=22 ~ Moderate 61% · n=14 ⚠ High Risk 89% · n=31

Click a leaf node or patient profile to read the full decision path and its clinical interpretation.

How to read the tree

Every path is a
complete clinical rule.

An e2tree is read top-down. At each internal node, the split condition routes the patient left (condition true) or right (condition false). When a leaf is reached, the prediction is the majority class at that node, weighted by ensemble structure.

The purity shown in each leaf (e.g. 87%) is the proportion of training observations that match the predicted class — a direct measure of local confidence. The ensemble purity is always higher than a standard CART tree trained on the same data.

Chest Pain Type ≤ 2

Root split — the ensemble's primary discriminator

Chest pain type (coded 1–4 by AHA criteria) is the single most informative feature across all 500 trees. Patients with typical angina (type 1) or asymptomatic pain (type 4, coded ≤ 2) follow the left branch; atypical or non-anginal pain goes right. This split alone separates 46% of the cohort with high confidence.

Thalassemia ≤ 2  |  Major Vessels ≤ 0  |  Age ≤ 54  |  Cholesterol ≤ 220

Second-level splits — context-dependent risk refinement

Each branch applies a different secondary criterion. For patients with chest pain ≤ 2, thalassemia type determines structural defect risk. For those with atypical pain, age is the gating factor. This mirrors the clinical heuristic: young patients with atypical symptoms are generally low risk regardless of other features.

Low Risk leaves — 87%, 79%, 73% purity

Three low-risk paths with differentiated confidence

The three green leaves represent patients the ensemble consistently routes to low risk, but with different confidence levels: 87% (no pain + normal thalassemia) is the most certain; 73% (normal thalassemia → no blocked vessels) is a softer low-risk call. Confidence tiers guide how aggressively to follow up.

High Risk leaf (81%) — the decisive path

Thalassemia defect + blocked vessel = critical signal

When a patient has mild or no angina but shows a reversible thalassemia defect and at least one blocked major vessel, 81% of training cases in this leaf had confirmed heart disease. This is the highest-confidence actionable rule in the tree, and directly aligns with standard cardiology risk criteria.

~
Moderate Risk leaf (61%) — the grey zone

Where the ensemble is least certain: investigate further

Older patients with atypical pain but controlled cholesterol split nearly evenly across the ensemble's trees — 61% purity is the lowest leaf. The e2tree preserves this uncertainty rather than forcing a binary decision — which is exactly right for borderline cases. Those are the patients who need a stress ECG, not a label.

Case II · Finance

Credit default prediction —
the right to an explanation.

European banking regulation (EBA guidelines, Art. 22 GDPR) requires that automated credit decisions be explainable to applicants on request. A standard ensemble achieves 0.84 AUC on the German Credit dataset, but a compliance officer cannot narrate its logic in an appeal tribunal.

e2tree produces a four-leaf tree that accounts for 89% of the ensemble's proximity structure. Each leaf is a self-contained underwriting rule: "Applicants aged under 30 with no checking account history are low risk if their loan duration is ≤ 18 months" is a statement a compliance officer can defend in writing.

Crucially, e2tree's variable importance ranking reveals that checking account status is the primary discriminator across the ensemble — a finding that would otherwise be buried in 500 trees of opaque split statistics, and that carries direct fairness-audit implications.

German Credit dataset
1,000
Applicants
20
Features
0.84
Ensemble AUC
4
e2tree leaves
regulatory compliance GDPR Art. 22 fairness audit
e2tree output — top decision rules
Checking status = A11 · Duration ≤ 18m

No checking account + short loan duration → Good credit (82% purity). The ensemble's strongest low-risk signal.

Checking status = A14 · Duration > 24m

Overdrawn account + long loan duration → Bad credit (79% purity). Clearest default signal across the ensemble.

Interactive explorer

Read every
underwriting rule.

Click a leaf or an applicant profile to animate the path and read the rule the model used — ready to paste into a GDPR Art. 22 explanation letter.

Applicant profiles
YES NO YES NO YES NO YES NO Duration ≤ 24 months Checking Acct ≤ 1 (low/neg.) Credit History ≤ 2 Loan Amount ≤ 3000 DM ⚠ Default 78% · n=145 ✓ Good Credit 84% · n=289 ⚠ Default 81% · n=101 ✓ Good Credit 63% · n=78 ⚠ Default 75% · n=54

Click a leaf or applicant profile to read the decision rule and its compliance interpretation.

Step-by-step

The e2tree compliance workflow.

library(e2tree) library(ranger) # faster for large n # 1 — Train with ranger ensemble <- ranger( credit_risk ~ ., data = credit_train, num.trees = 500, importance = "impurity" ) # 2 — Dissimilarity (parallel, 4 cores) D <- createDisMatrix( ensemble, data = credit_train, label = "credit_risk", parallel = list(active = TRUE, no_cores = 4) ) # 3 — Shallow tree for regulatory legibility setting <- list( impTotal = 0.10, maxDec = 0.015, n = 10, level = 3 ) tree <- e2tree( credit_risk ~ ., credit_train, D, ensemble, setting ) # 4 — Print IF-THEN rules for compliance report summary(tree) # 5 — Variable importance for fairness audit vi <- vimp(tree, data = credit_train) vi$g_imp # ggplot2 importance chart

Why this matters for compliance

01

Auditability

summary(tree) outputs each terminal node as an explicit IF-THEN rule that can be quoted verbatim in a GDPR Art. 22 explanation letter to a loan applicant.

02

Fairness auditing

vimp() reveals which features the ensemble actually relied on most. If a protected characteristic (age, gender) appears in the top splits, it triggers an immediate bias review.

03

Predictive parity

Because e2tree preserves the ensemble's proximity structure (not just class predictions), the explainability is faithful to the model's actual decision logic — not a post-hoc approximation.

04

Grey-zone routing

Low-purity leaves directly flag borderline applicants for human review — operationalising the "meaningful human oversight" requirement of automated decision systems.

Case III · Industry

Machine failure prediction —
regression, same logic.

A manufacturing plant operates 500 CNC machines. An ensemble of decision trees predicts remaining useful life (RUL, in hours) from sensor readings — a regression problem. The ensemble achieves RMSE = 12h on the test set, but maintenance planners need to know which sensor conditions drove a short-RUL prediction.

The regression e2tree partitions the sensor space into four regions with distinct RUL profiles. A maintenance engineer can read the tree and say: "If air temperature is above 305 K and rotational speed exceeds 1450 rpm, schedule maintenance within 24 hours." No data science degree required.

Local Observation Importance (loi()) shows which specific sensors drove the short-RUL prediction for each individual machine — enabling targeted diagnostic interventions rather than blanket shutdowns.

AI4I Predictive Maintenance dataset
10k
Observations
6
Sensor features
12h
Ensemble RMSE
4
e2tree leaves
regression RUL prediction sensor data
e2tree leaves — RUL segments
Air Temp ≤ 305 K · Speed ≤ 1450 rpm

Mean RUL = 142h. Normal operating zone — no immediate intervention.

Air Temp > 305 K · Speed > 1450 rpm · Tool Wear > 200

Mean RUL = 8h. Schedule maintenance immediately.

Interactive explorer

Trace every
maintenance decision.

Click a leaf or a machine profile to animate the sensor path and read the maintenance recommendation — RUL prediction with full context.

Machine profiles
YES NO YES NO YES NO YES NO Air Temp ≤ 305 K Rot. Speed ≤ 1450 rpm Tool Wear ≤ 180 min Torque ≤ 42 Nm RUL: 142 h Safe · operate RUL: 68 h Monitor speed RUL: 12 h ⚠ Stop immediately RUL: 55 h Schedule maint. RUL: 31 h Prioritize

Click a leaf or machine profile to read the sensor path and its maintenance recommendation.

Regression workflow

Same API.
Continuous response.

The only difference from the classification workflow is the response variable type. e2tree adapts its dissimilarity weighting automatically.

library(e2tree) library(randomForest) # 1 — Train: predict remaining useful life (hours) ensemble_rul <- randomForest( RUL ~ ., data = maint_train, ntree = 500, importance = TRUE, proximity = TRUE ) # 2 — Dissimilarity for continuous response D_rul <- createDisMatrix( ensemble_rul, data = maint_train, label = "RUL", # continuous — regression mode parallel = list(active = TRUE, no_cores = 4) ) # 3 — Fit regression e2tree setting <- list(impTotal = 0.08, maxDec = 0.01, n = 50, level = 3) tree_rul <- e2tree( RUL ~ ., maint_train, D_rul, ensemble_rul, setting ) # 4 — Predict on test set pred_rul <- predict(tree_rul, newdata = maint_test) # 5 — Per-machine sensor attribution (LOI) loi_rul <- loi( tree_rul, ensemble_rul, maint_train, "RUL" ) plot(loi_rul)
How to read regression leaves

Leaf values are
predicted means.

In a regression e2tree, each terminal node predicts the mean response of training observations in that node, weighted by the ensemble's dissimilarity structure. This is analogous to CART regression but guided by ensemble proximity rather than squared-error impurity.

Split conditions

Same structure as classification: IF condition THEN go left, ELSE go right. Multiple splits chain into a path that narrows to a specific operating regime.

μ

Leaf value = predicted RUL

The predicted value for a new machine is the mean RUL of the training observations that share its leaf. Leaf width (spread of training RUL values) corresponds to local uncertainty — narrow leaves signal high-confidence predictions.

σ

High-uncertainty leaves flag grey zones

A leaf with high variance in training RUL values indicates a region where the ensemble was less certain. These are the machines that need additional sensor monitoring, not just a scheduled maintenance date.

LOI

Local Importance for sensor attribution

loi() reveals which sensor reading most influenced the RUL estimate for each individual machine — a crucial diagnostic insight that no aggregate importance score can provide.

Method comparison

How does e2tree compare
to the alternatives?

e2tree occupies a unique position: it is not a post-hoc approximation (like LIME or SHAP), nor does it sacrifice predictive power (like plain CART). It is a faithful structural surrogate that preserves the ensemble's logic.

Method Interpretability Faithful to ensemble Global rules Regression No approximation
e2tree Single decision tree Structurally IF-THEN rules Exact surrogate
Full ensemble (RF) Black box Is the model
Plain CART Single tree Independent model ~ Lower accuracy
LIME ~ Per-instance ~ Local approximation No global rules Approximates locally
SHAP ~ Feature attributions Game-theoretic No decision rules ~ TreeSHAP is exact
Surrogate tree (naïve) Single tree ~ Prediction-level only Misses structure

"Faithful to ensemble" means the explainer reflects the ensemble's internal structure (proximity/co-occurrence), not just its output predictions.

Start explaining your ensemble.

Install from CRAN. Five lines of R. One interpretable tree.