← Blog/blog/critical-predicate-is-not-repair

The threshold that flips a tree ensemble but does not repair it

A feature attribution can say that age mattered. A counterfactual can say that a smaller age would change the answer. Barbon Junior and Longo ask a more structural question: which threshold did the trained trees actually execute, and which shared threshold is most capable of moving this prediction toward another class?

Their answer is the critical predicate: an executed test such as x₀ > 0.50, chosen from the paths followed by one sample. It is concrete, auditable, and often changes the prediction. The useful warning is just as concrete: changing one mistaken prediction is not evidence that changing the model at that threshold will improve new predictions.

01

Keep the computation the ensemble actually ran

A predicate is one branch condition in a decision tree, for example “feature 3 is at most 7.4.” For one sample, every tree follows a root-to-leaf path. The local Decision Predicate Graph, or local DPG, merges those executed paths while retaining which trees used every predicate and which class each reached.

This matters because the full graph's class support is computed from the ensemble's original per-tree contributions—not by counting leaf labels. Random forests average leaf probabilities; boosting models add signed scores and then apply their link function. That accounting reproduced all 342,040 predictions in the study, with a largest numerical residual of 1.4 × 10⁻¹⁴.

02

Estimate the best threshold to cross

For each executed predicate, the algorithm crosses that threshold in the one tree that executed it while leaving every other tree fixed. Changes in target-class support are summed for predicates sharing the same six-decimal label. Positive-gain predicates are pivots; the largest is critical, with smaller slack—the distance from sample to threshold—used as a tie-breaker.

def critical_predicate(forest, x, target):
    base = ensemble_support(forest, x)[target]
    gain = {}
    for tree in forest:
        trace, old = trace_tree(tree, x)
        for predicate in trace:
            crossed = cross(x, predicate)
            new = evaluate_tree(tree, crossed)[target]
            gain[predicate.label] = gain.get(predicate.label, 0) + (new - old[target]) / len(forest)
    pivots = [(label, value) for label, value in gain.items() if value > 0]
    return max(pivots, key=lambda item: (item[1], -slack(item[0], x))) if pivots else None

# Then cross the selected threshold once and re-evaluate the whole forest.
03

A three-tree audit by hand

Our deterministic forest predicts class 1 with support 0.7 for the sample [0.62, 0.40]. Two trees execute x₀ > 0.50. Crossing it gives an estimated class-0 gain of 0.4. The whole forest gains 0.5 because a third tree also crosses its separate 0.55 threshold. Support becomes [0.8, 0.2], flipping the class.

target class 0 supportpredicted class 1 support
Target support around the toy sample. The discontinuities are the exact thresholds used by the three trees. Deterministic illustrative data computed by the pure core module.
The paper's one-tree-at-a-time gain estimate versus the result of crossing the selected feature in the whole toy forest. Deterministic illustrative data.
04

What the 16-dataset study found

The authors trained 100-estimator random forests, bagged trees, gradient-boosting machines, and AdaBoost models on 16 numeric classification datasets. Depth was selected only by validation accuracy; explanation metrics did not tune the models. Each result is averaged across datasets and ten model initializations.

EnsembleCriticalRandomNearestTreeSHAP feature
Random forest18.1%5.2%0.7%1.0%
Bagging42.8%9.5%1.1%2.2%
Gradient boosting42.4%10.1%1.8%5.9%
AdaBoost41.1%12.9%5.2%10.6%
Paper-reported proportion of predictions changed after one selected-predicate crossing (Table 3). TreeSHAP means the nearest executed threshold on its top-ranked feature, not TreeSHAP itself returning a threshold.

When the true label of a wrong prediction is known, the method can target that class rather than the strongest competing class. This distinction matters in multiclass data: the true class was not the top competitor in 18–31% of mistakes, and targeting it raised recovery by 6–13 percentage points.

EnsembleCritical predicateTreeSHAP feature
Random forest45.6%29.3%
Bagging67.7%49.8%
Gradient boosting69.2%50.1%
AdaBoost67.7%44.3%
Paper-reported share of wrong predictions recovered by one crossing toward the true class (Table 4b).
05

Why the obvious patch can fail

In the toy audit set, moving the two shared 0.50 thresholds to 0.65 fixes the focal mistake. It simultaneously breaks a nearby point whose true class is 1. Accuracy therefore stays at two out of three. The numbers are deliberately small enough to inspect; they demonstrate the same logical gap as the paper's negative repair result.

A local threshold edit fixes one toy sample and harms another, leaving audit accuracy unchanged. Deterministic illustrative data, not a paper-reported experiment.

A crossing also need not be plausible. In the paper it moved one feature by 0.88–1.34 standard deviations on average and raised the atypical-sample rate from 5% to 15–22%, roughly the same range as the counterfactual baselines. Recovery proves only that the model's output changes to the recorded label under that intervention.

06

Where the method stops

Shared thresholds are central to the mechanism, but random-forest thresholds were shared by only 1.05–2.37 trees on average outside the iris dataset. Randomized-threshold ensembles would need interval grouping. The implementation covers numeric classification; regression, categorical splits, and histogram-based boosting need extensions.

The complete local DPG is intentionally a verifiable record, not a compact visualization, and no user study tested whether people understand it. Anchors and LORE ran on smaller subsets because of cost. The experiments identify associations between errors and predicates on public datasets; real debugging still needs more data around a threshold, retraining, and a held-out evaluation.

07

What to probe next

Treat the critical predicate as a testable hypothesis. Collect or inspect samples on both sides of its threshold, separate target-support gain from feature distance, and measure continuity across neighboring inputs. Compare a retrained edit against the unchanged model on a locked test set; reject any patch that merely trades one local error for another. The site's decision-tree, random-forest, and XGBoost pages expose the underlying path and ensemble mechanics from scratch.

References

  1. Barbon Junior, S., & Longo, L. (2026). Where Tree Ensembles Decide: Structural Local Explanation with Decision Predicate Graphs. Knowledge-Based Systems / arXiv:2611.18382
  2. Arrighi, L., Pennella, L., Tavares, G. M., & Barbon Junior, S. (2024). Decision Predicate Graphs: Enhancing Interpretability in Tree Ensembles. World Conference on Explainable Artificial Intelligence