AnchorExplainer<T>

Models & Types · AiDotNet.Interpretability.Explainers

Model-agnostic Anchor explainer that provides rule-based explanations.

Implements: ILocalExplainer<T, AnchorExplanation<T>>

For Beginners

Anchors are “if-then” rules that explain predictions. Unlike SHAP or LIME which give feature weights, Anchors give you rules like: “IF Age > 30 AND Income > 50000 THEN the model predicts ‘Approved’”

Key concepts:

  • Precision: How often the rule correctly predicts the same outcome (e.g., 95% of the time)
  • Coverage: What fraction of all instances the rule applies to

Anchors are great when you need to explain to non-technical stakeholders because rules are intuitive and easy to understand.

Example output: “The loan was approved because Age >= 25 AND CreditScore >= 700” This rule holds for 95% of similar applicants (precision) and covers 30% of all applicants (coverage).

Constructors

Constructor Summary
AnchorExplainer(Func<Matrix<T>, Vector<T>> predictFunction, int numFeatures, double precisionThreshold, int maxAnchorSize, int beamWidth, int nSamples, string[] featureNames, T[] featureMins, T[] featureMaxs, int? randomState) Initializes a new Anchor explainer.

Properties

Property Summary
bool SupportsGlobalExplanations { get; }
bool SupportsLocalExplanations { get; }
string MethodName { get; }

Methods

Method Summary
AnchorExplanation<T> Explain(Vector<T> instance)
AnchorExplanation<T>[] ExplainBatch(Matrix<T> instances)