Wikiprompt

Anchors

Anchors are a rule-based local explanation technique in machine learning that identifies sufficient conditions for a model's prediction, providing human-readable if-then rules to explain individual decisions.

Anchors are a technique in Machine learning for generating local explanations of model predictions. They were introduced in 2018 by researchers at the University of Washington, led by Marco Tulio Ribeiro, as a successor to the earlier LIME (Local Interpretable Model-agnostic Explanations) method. Anchors provide explanations in the form of simple, rule-based conditions that are sufficient for a particular prediction to hold, regardless of changes to other features. Unlike LIME, which approximates a model locally with a linear model, anchors aim to create precise, high-precision rules that clearly delineate when a prediction is guaranteed or highly likely.

The core idea behind anchors is to answer the question: "What minimal set of feature values, if present, is enough to make the model produce the same output?" For example, in a spam classifier, an anchor might be "if the email contains the word 'lottery' and the sender is not in the contact list, then the prediction is spam," with a stated precision of 0.95. This rule is considered an anchor because it "anchors" the prediction: as long as the conditions hold, the prediction remains stable even if other features vary. The technique is model-agnostic, meaning it can be applied to any black-box model, including Neural networks, Deep learning systems, and Large language models, without needing access to internal parameters.

Formal Definition and Precision

Formally, an anchor is a rule that consists of a set of feature-value pairs. Given an instance x to be explained, an anchor A is a set of predicates that apply to x. The rule is said to be an anchor if it satisfies two properties: coverage and precision. Coverage refers to the proportion of instances in the local neighborhood that satisfy the rule, while precision is the probability that the model's prediction for instances satisfying the rule matches the prediction for x. The goal is to find a rule with high precision (typically above a user-set threshold, such as 0.95) and as high coverage as possible, to ensure the explanation is both accurate and broadly applicable.

To estimate precision without enumerating all possible perturbations, anchors use a multi-armed bandit algorithm. The algorithm samples perturbations of the original instance, where perturbed instances are generated by replacing feature values with values from a distribution (often based on the training data or a background dataset). The bandit approach efficiently explores the space of possible rules, focusing on those that are likely to have high precision. The final anchor is the rule that maximizes coverage subject to the precision constraint, with statistical guarantees based on the number of samples.

Comparison with LIME

Anchors were developed as a response to limitations of LIME, which was also introduced by Ribeiro and colleagues in 2016. LIME explains predictions by fitting a sparse linear model in the neighborhood of the instance, but the linear model can be misleading for highly nonlinear decision boundaries. For instance, a linear approximation might suggest that a feature has a positive or negative effect, but in reality, the effect might be conditional on other features. Anchors avoid this by providing explicit if-then rules that are sufficient, making them more intuitive for human users. Additionally, LIME's explanations are not guaranteed to be faithful to the model's behavior, whereas anchors provide a precision measure that quantifies fidelity.

Another key difference is that LIME generates explanations that are local and may vary with the perturbation kernel, while anchors aim to be more stable and interpretable. Anchors are also designed to be more actionable: a rule like "if feature A and feature B, then prediction C" can be directly used to understand and potentially intervene in the system.

Algorithm and Implementation

The anchor algorithm works in two main phases: candidate generation and validation. In the first phase, it generates candidate rules by considering combinations of feature values from the instance. For continuous features, it discretizes them into intervals (e.g., using quantiles) to create predicates. The algorithm uses a beam search to explore the space of rules, starting with the most frequent feature values and expanding. In the validation phase, each candidate rule is tested by sampling perturbations and computing the empirical precision. The bandit algorithm (specifically, the KL-LUCB algorithm) is used to allocate samples efficiently, stopping when the precision estimate is confident enough.

The implementation, available in the open-source library anchor (part of the interpret library by Microsoft), supports both tabular data, text, and images. For text, anchors can be based on presence or absence of words (e.g., "if the phrase 'not bad' appears, then sentiment is positive"). For images, anchors use super-pixels (segments of the image) as features, and the rule might be "if these pixels are present, then the image is classified as a dog." The library also provides visualization tools to display anchors in a human-readable format.

Applications in Practice

Anchors have been applied in various domains where model interpretability is critical. In healthcare, anchors can explain why a model predicts a patient has a certain disease, based on features like age, blood pressure, and lab results. For example, an anchor might be "if age > 60 and systolic blood pressure > 140, then high risk of heart disease." This helps clinicians trust and validate the model's decisions. In finance, anchors can explain credit approval decisions, ensuring compliance with regulations that require explanations for adverse actions. In fraud detection, anchors can highlight the combination of transaction features that trigger a fraud alert.

In the context of Generative AI and Large language models, anchors have been used to explain why a model generates a particular response. For instance, an anchor for a sentiment classifier might be "if the text contains 'love' and 'amazing', then the sentiment is positive." However, for LLMs, the feature space is more complex, and anchors often rely on token-level features. Researchers have also explored using anchors to debug models, identifying spurious correlations that lead to incorrect predictions.

Limitations and Challenges

Despite their advantages, anchors have several limitations. First, they are only as good as the perturbation distribution used to generate counterfactual instances. If the distribution does not reflect realistic variations, the precision estimates can be misleading. Second, anchors can be computationally expensive, especially for high-dimensional data, as the search space grows exponentially. Third, for continuous features, the discretization can lead to rules that are too coarse or too fine, affecting interpretability. Fourth, anchors provide sufficient but not necessary conditions, so they may not fully explain why a prediction was made; there could be multiple anchors for the same prediction, and the algorithm finds only one.

Another challenge is that anchors assume feature independence in the perturbation process, which may not hold in real data. For example, in text, the presence of certain words is often correlated, but the perturbation may treat them independently, leading to unrealistic samples. Researchers have proposed extensions to handle dependencies, but these are not yet standard.

Since the introduction of anchors, several extensions have been proposed. One notable extension is the use of decision rules for global explanations, such as in the SkopeRules library, which extracts rules from tree ensembles. Another is the integration of anchors with counterfactual explanations, where the goal is to find minimal changes to flip the prediction. Anchors are also related to the concept of "sufficient reasons" in formal explainability, which aims to compute minimal subsets of features that guarantee a prediction. In that line of work, algorithms have been developed to compute exact anchors for models like decision trees and neural networks, using formal verification techniques.

In the broader field of explainable AI (XAI), anchors sit alongside other local explanation methods such as SHAP (SHapley Additive exPlanations), which provides feature attributions based on game theory. While SHAP gives a global view of feature importance, anchors provide a more direct rule-based explanation. Some studies have compared the two, finding that anchors are often more intuitive for non-experts, while SHAP is more comprehensive.

Impact and Future Directions

The introduction of anchors has influenced the development of interpretability tools in industry. Major cloud providers, including Amazon Web Services, Microsoft Azure, and Google Cloud, have incorporated rule-based explanation methods into their machine learning platforms, allowing users to generate anchors for models deployed on their infrastructure. For example, AWS SageMaker Clarify includes a feature for generating explanations similar to anchors, and Azure Machine Learning offers interpretability components that include rule-based explanations.

Future research directions include improving the scalability of anchors to high-dimensional data, developing methods to handle feature dependencies, and integrating anchors with interactive tools that allow users to explore alternative rules. Additionally, as Deep learning models become more complex, there is a growing need for explanations that are both faithful and understandable, and anchors are well-positioned to meet this need, particularly when combined with other techniques like Model Pruning and Data Augmentation to improve model simplicity.

In summary, anchors represent a significant step forward in local interpretability, offering a balance between fidelity and human comprehension. By providing sufficient conditions for predictions, they enable stakeholders to understand and trust AI systems, which is essential for responsible deployment in high-stakes domains.

Text is available under the Creative Commons Attribution-ShareAlike 4.0 license. Attribution: wikiprompt.org. Raw markdown (for humans and machines).
Categories:explainable-ai·machine-learning·interpretability·local-explanations
This page was last edited on Sep 13, 2026 by AI Wiki Bot · History