TRACK A · 11.1.2

Anchors

For instance x and black-box model f, find a predicate conjunction A satisfied by x whose covered instances usually receive the same prediction. It is a local behavioral explanation, not a causal mechanism or global surrogate.

Learning outcomes

1. Goal.

For instance x and black-box model f, find a predicate conjunction A satisfied by x whose covered instances usually receive the same prediction. It is a local behavioral explanation, not a causal mechanism or global surrogate.

Use predicates actually satisfied by the instance and fix the target prediction separately.

2. Definitions.

For Z drawn from D, precision = P(f(Z)=f(x) | A(Z)=1), coverage = P(A(Z)=1). Precision measures model agreement, not agreement with ground truth; zero coverage leaves precision undefined.

Unlike classifier precision, the denominator is covered instances and the numerator is agreements with the reference prediction.

3. Optimization.

Maximize coverage subject to precision ≥ τ. Finite samples require uncertainty control with error level δ. The original approach employs probabilistic bounds and adaptive search; the finite enumeration here does not reproduce those guarantees.

When admissible rules tie on coverage, shorter length can be a secondary criterion rather than the primary goal.

4. Worked example.

Let f(a,b,c)=a AND (b OR c), x=(1,1,0), eight equally likely binary rows. a=1 covers 4/8 and agrees on 3/4; a=1 AND b=1 covers 2/8 and agrees on 2/2. Choose the latter at τ=0.9, the former at τ=0.7.

The four a=1 rows are 100, 101, 110, 111. Only 100 predicts zero; adding b=1 removes this counterexample.

APrecisionCoverage
a=175%50%
a=1 AND b=1100%25%

Admissible rule: a=1

5. Distribution shift.

Tripling weights of b=1 rows raises precision of a=1 from 0.75 to 0.875, coverage unchanged at 0.5. The model stays fixed. Record the perturbation distribution and evaluation sample.

Evaluate against the target distribution: changed frequencies can invalidate an old anchor.

6. Search.

Generate predicates true of x, estimate candidates, extend promising conjunctions, check uncertainty bounds, then select the admissible rule with greatest coverage. Abstain when no trustworthy anchor is established.

Adaptive search does not justify treating all estimates as independent. Separate search from final evaluation.

7. Uncertainty.

For an independent fixed-rule evaluation with n covered observations, a one-sided Hoeffding lower bound is max(0,p̂−sqrt(log(1/δ)/(2n))). At n=100, p̂=0.95, δ=0.05 it is about 0.828. Adaptive candidate selection requires independent evaluation or multiplicity control.

Even 95 agreements out of 100 do not automatically guarantee 95% precision. Consider sample size and selection error.

8. Comparison.

LIME provides local weights, SHAP allocates a prediction relative to a baseline, Anchors describes a rule's applicability region. Correlated features can make artificial perturbations unrealistic.

Causal questions require additional assumptions and evidence, beyond any of these three explanation methods.

9. Lab.

Run lab.py to enumerate all subsets of three features under a finite distribution. Compare τ=0.7 and 0.9, change row frequencies and explain precision/coverage shifts without changing the model or inferring causality.

Compare with the hand calculation and record threshold, coverage and precision.

Practice

Run lab.py to enumerate all subsets of three features under a finite distribution. Compare τ=0.7 and 0.9, change row frequencies and explain precision/coverage shifts without changing the model or inferring causality.

python a-11-1-2-anchors.py

Python

0.7 ((0,), 0.5, 0.75)
0.9 ((0, 1), 0.25, 1.0)
shifted (0.5, 0.875)

Sources

Glossary

Goal.
For instance x and black-box model f, find a predicate conjunction A satisfied by x whose covered instances usually receive the same prediction. It is a local behavioral explanation, not a causal mechanism or global surrogate.
Definitions.
For Z drawn from D, precision = P(f(Z)=f(x) | A(Z)=1), coverage = P(A(Z)=1). Precision measures model agreement, not agreement with ground truth; zero coverage leaves precision undefined.
Optimization.
Maximize coverage subject to precision ≥ τ. Finite samples require uncertainty control with error level δ. The original approach employs probabilistic bounds and adaptive search; the finite enumeration here does not reproduce those guarantees.
Worked example.
Let f(a,b,c)=a AND (b OR c), x=(1,1,0), eight equally likely binary rows. a=1 covers 4/8 and agrees on 3/4; a=1 AND b=1 covers 2/8 and agrees on 2/2. Choose the latter at τ=0.9, the former at τ=0.7.
Distribution shift.
Tripling weights of b=1 rows raises precision of a=1 from 0.75 to 0.875, coverage unchanged at 0.5. The model stays fixed. Record the perturbation distribution and evaluation sample.
Search.
Generate predicates true of x, estimate candidates, extend promising conjunctions, check uncertainty bounds, then select the admissible rule with greatest coverage. Abstain when no trustworthy anchor is established.
Uncertainty.
For an independent fixed-rule evaluation with n covered observations, a one-sided Hoeffding lower bound is max(0,p̂−sqrt(log(1/δ)/(2n))). At n=100, p̂=0.95, δ=0.05 it is about 0.828. Adaptive candidate selection requires independent evaluation or multiplicity control.
Comparison.
LIME provides local weights, SHAP allocates a prediction relative to a baseline, Anchors describes a rule's applicability region. Correlated features can make artificial perturbations unrealistic.

Self-check

precision(a=1)
coverage(a=1 AND b=1)
precision(a=1), shifted D