Interpretability, attribution, and explanation audits · Interpretability, explanations, and model-mechanism analysis · EXP016 · Algorithm
Anchors: high-precision rule explanations
Find an interpretable rule whose satisfaction makes a model’s prediction stable with high precision under a declared perturbation distribution, while seeking useful coverage.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
- Anchors for a saved model Experimental
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Complete calculation
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through explain.anchors. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Find an interpretable rule whose satisfaction makes a model’s prediction stable with high precision under a declared perturbation distribution, while seeking useful coverage.
Question / hypotheses
For cases satisfying this rule, how often does the model retain the target prediction under the chosen sampling process, and how broadly does the rule apply?
Architecture / computational structure
Candidate feature predicates are combined into rules. Conditional perturbation sampling estimates agreement with the explained prediction. A search procedure uses uncertainty-aware selection to seek high-coverage rules whose precision exceeds a threshold.
Assumptions
The conditional perturbation distribution defines the meaning of precision and coverage. Sampling must obey the rule and preserve meaningful inputs. Search adaptivity requires valid confidence handling; a single post-selection binomial interval is not automatically a simultaneous search guarantee.
Formula / computational definition
Parameters and notation
Predictor weights are fixed. Choices include predicate discretization, conditional sampler, precision target τ, confidence budget δ, beam width, tolerance, sample cap and maximum rule length. Precision here means agreement with the model, not correctness against ground-truth labels. Here x is the explained case, Z a draw from the declared perturbation distribution, A a Boolean rule, and A-hat a rule returned by a randomized search. The outer probability in the displayed guarantee is over the search sampling, not a posterior probability about a fixed rule.
Fitting, fine-tuning, and adaptation
Recompute rules after adaptation or population changes. Hold the explanation sampling protocol fixed for comparisons. If using fresh independent validation draws for a selected rule, distinguish that validation interval from the confidence accounting used during adaptive search.
How to use and calibrate
Report the rule, estimated precision with uncertainty, coverage, sampling budget and generator. Inspect cases near predicate boundaries and alternative plausible sampling distributions. A rule matching only one input may have excellent precision and negligible utility.
Example application
Validate a fixed candidate rule on independently generated cases satisfying it, then show the trade-off between a more restrictive rule and its population coverage.
Interpretation / pitfalls
Watch out
High model-agreement precision does not imply correct predictions. Unrealistic perturbations distort the rule’s meaning. An adaptive search can exploit sampling noise unless its confidence budget is handled appropriately.
Python and R code examples
Scope: One-sided exact lower confidence bound for an already fixed rule on independent validation draws; no adaptive Anchors search. Python: SciPy. R: stats.
Validation: Python executed successfully on the supplied fixture; R reviewed but unexecuted. Full implementations and supported operation details are provided in the linked primary/official sources.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Complete calculation — One-sided exact lower confidence bound for an already fixed rule on independent validation draws; no adaptive Anchors search. · needs scipy
from scipy.stats import beta
n,k,delta,tau=200,198,.05,.95
lower=beta.ppf(delta,k,n-k+1)
print({"agreement":k/n,"lower":float(lower),"passes_fixed_rule_check":lower>=tau})
assert 0<lower<k/n
Complete calculation — One-sided exact lower confidence bound for an already fixed rule on independent validation draws; no adaptive Anchors search.
n<-200;k<-198;delta<-.05;tau<-.95
lower<-qbeta(delta,k,n-k+1);print(list(agreement=k/n,lower=lower,passes_fixed_rule_check=lower>=tau))
stopifnot(lower>0,lower<k/n)
Sources
- Source 1homes.cs.washington.edu
- Source 2github.com
From the CodeSplash reference, entry EXP016.