LIMEExplainer<T>

Models & Types · AiDotNet.Interpretability.Explainers

Model-agnostic LIME (Local Interpretable Model-agnostic Explanations) explainer.

Implements: IGPUAcceleratedExplainer<T>, ILocalExplainer<T, LIMEExplanationResult<T>>

For Beginners

LIME explains individual predictions by building a simple, interpretable model (like linear regression) that approximates the complex model locally around the prediction you want to understand.

How it works:

  1. Generate perturbed samples near your instance (slightly modified versions)
  2. Get the complex model’s predictions for these samples
  3. Fit a simple linear model to these nearby predictions
  4. The linear model’s coefficients show which features matter most

Think of it like zooming in on a curvy road - if you zoom in enough, even a curved road looks straight. LIME zooms in on your prediction and fits a “straight line” (linear model) to explain it.

Constructors

Constructor Summary
LIMEExplainer(Func<Matrix<T>, Vector<T>> predictFunction, int numFeatures, int nSamples, double kernelWidth, string[] featureNames, double[] featureStdDevs, int? randomState) Initializes a new LIME explainer.

Properties

Property Summary
bool IsGPUAccelerated { get; }
bool SupportsGlobalExplanations { get; }
bool SupportsLocalExplanations { get; }
int NumFeatures { get; } Gets the number of features being explained.
string MethodName { get; }

Methods

Method Summary
LIMEExplainer<T> FromModel(IFullModel<T, TInput, TOutput> model, int numFeatures, int nSamples, double kernelWidth, string[] featureNames, double[] featureStdDevs, int? randomState) Creates a LIME explainer from a model.
LIMEExplanationResult<T> Explain(Vector<T> instance)
LIMEExplanationResult<T>[] ExplainBatch(Matrix<T> instances)
void SetGPUHelper(GPUExplainerHelper<T> helper)