GlobalSurrogateExplainer<T>

Models & Types · AiDotNet.Interpretability.Explainers

Global Surrogate Model explainer that approximates a complex model with an interpretable one.

Implements: IGlobalExplainer<T, SurrogateExplanation<T>>

For Beginners

A global surrogate model is a simple, interpretable model (like linear regression or a decision tree) that tries to mimic a complex “black box” model.

How it works:

  1. Use the complex model to make predictions on a dataset
  2. Train a simple model to predict what the complex model predicts
  3. Analyze the simple model to understand the complex one

Think of it like having a translator explain a complex foreign language document. The translator (surrogate model) isn’t perfect, but they can explain the main ideas in a way you understand.

The R² score tells you how well the surrogate approximates the black box:

  • R² close to 1.0 = surrogate explains the black box well
  • R² far from 1.0 = surrogate is too simple to capture the black box behavior

Constructors

Constructor Summary
GlobalSurrogateExplainer(Func<Matrix<T>, Vector<T>> blackBoxPredictFunction, int numFeatures, string[] featureNames) Initializes a new Global Surrogate explainer.

Properties

Property Summary
T Fidelity { get; } Gets the fidelity (R²) of the surrogate model.
bool IsFitted { get; } Gets whether the surrogate model has been fitted.
bool SupportsGlobalExplanations { get; }
bool SupportsLocalExplanations { get; }
int NumFeatures { get; } Gets the number of features.
string MethodName { get; }

Methods

Method Summary
GlobalSurrogateExplainer<T> FromModel(IFullModel<T, TInput, TOutput> blackBoxModel, int numFeatures, string[] featureNames) Creates a Global Surrogate explainer from a model.
SurrogateExplanation<T> ExplainGlobal(Matrix<T> data)
ValueTuple<Vector<T>, Vector<T>, T> Compare(Matrix<T> X) Compares the surrogate predictions with the black box predictions.
Vector<T> PredictSurrogate(Matrix<T> X) Uses the surrogate model to make predictions.
void Fit(Matrix<T> X) Fits the surrogate model to approximate the black box on the given data.