Table of Contents

Interface IInterpretableModel<T>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Interface for models that support interpretability features.

public interface IInterpretableModel<T>

Type Parameters

T

The numeric type for calculations.

Methods

ConfigureFairness(Vector<int>, params FairnessMetric[])

Configures fairness evaluation settings.

void ConfigureFairness(Vector<int> sensitiveFeatures, params FairnessMetric[] fairnessMetrics)

Parameters

sensitiveFeatures Vector<int>

The indices of sensitive features.

fairnessMetrics FairnessMetric[]

The fairness metrics to evaluate.

EnableMethod(params InterpretationMethod[])

Enables specific interpretation methods.

void EnableMethod(params InterpretationMethod[] methods)

Parameters

methods InterpretationMethod[]

The methods to enable.

GenerateTextExplanationAsync(Tensor<T>, Tensor<T>)

Generates a text explanation for a prediction.

Task<string> GenerateTextExplanationAsync(Tensor<T> input, Tensor<T> prediction)

Parameters

input Tensor<T>

The input data.

prediction Tensor<T>

The prediction made by the model.

Returns

Task<string>

A text explanation of the prediction.

GetAnchorExplanationAsync(Tensor<T>, T)

Gets anchor explanation for a given input.

Task<AnchorExplanation<T>> GetAnchorExplanationAsync(Tensor<T> input, T threshold)

Parameters

input Tensor<T>

The input to explain.

threshold T

The threshold for anchor construction.

Returns

Task<AnchorExplanation<T>>

An anchor explanation.

GetCounterfactualAsync(Tensor<T>, Tensor<T>, int)

Gets counterfactual explanation for a given input and desired output.

Task<CounterfactualExplanation<T>> GetCounterfactualAsync(Tensor<T> input, Tensor<T> desiredOutput, int maxChanges = 5)

Parameters

input Tensor<T>

The input to analyze.

desiredOutput Tensor<T>

The desired output.

maxChanges int

The maximum number of changes allowed.

Returns

Task<CounterfactualExplanation<T>>

A counterfactual explanation.

GetFeatureInteractionAsync(int, int)

Gets feature interaction effects between two features.

Task<T> GetFeatureInteractionAsync(int feature1Index, int feature2Index)

Parameters

feature1Index int

The index of the first feature.

feature2Index int

The index of the second feature.

Returns

Task<T>

The interaction effect value.

GetGlobalFeatureImportanceAsync()

Gets the global feature importance across all predictions.

Task<Dictionary<int, T>> GetGlobalFeatureImportanceAsync()

Returns

Task<Dictionary<int, T>>

A dictionary mapping feature indices to importance scores.

GetLimeExplanationAsync(Tensor<T>, int)

Gets LIME explanation for a specific input.

Task<LimeExplanation<T>> GetLimeExplanationAsync(Tensor<T> input, int numFeatures = 10)

Parameters

input Tensor<T>

The input to explain.

numFeatures int

The number of features to include in the explanation.

Returns

Task<LimeExplanation<T>>

A LIME explanation.

GetLocalFeatureImportanceAsync(Tensor<T>)

Gets the local feature importance for a specific input.

Task<Dictionary<int, T>> GetLocalFeatureImportanceAsync(Tensor<T> input)

Parameters

input Tensor<T>

The input to analyze.

Returns

Task<Dictionary<int, T>>

A dictionary mapping feature indices to importance scores.

GetModelSpecificInterpretabilityAsync()

Gets model-specific interpretability information.

Task<Dictionary<string, object>> GetModelSpecificInterpretabilityAsync()

Returns

Task<Dictionary<string, object>>

A dictionary of model-specific interpretability information.

GetPartialDependenceAsync(Vector<int>, int)

Gets partial dependence data for specified features.

Task<PartialDependenceData<T>> GetPartialDependenceAsync(Vector<int> featureIndices, int gridResolution = 20)

Parameters

featureIndices Vector<int>

The feature indices to analyze.

gridResolution int

The grid resolution to use.

Returns

Task<PartialDependenceData<T>>

Partial dependence data.

GetShapValuesAsync(Tensor<T>)

Gets SHAP values for the given inputs.

Task<Matrix<T>> GetShapValuesAsync(Tensor<T> inputs)

Parameters

inputs Tensor<T>

The inputs to analyze.

Returns

Task<Matrix<T>>

A matrix containing SHAP values.

SetBaseModel<TInput, TOutput>(IFullModel<T, TInput, TOutput>)

Sets the base model for interpretability analysis.

void SetBaseModel<TInput, TOutput>(IFullModel<T, TInput, TOutput> model)

Parameters

model IFullModel<T, TInput, TOutput>

The base model. Must implement IFullModel.

Type Parameters

TInput

The input type for the model.

TOutput

The output type for the model.

ValidateFairnessAsync(Tensor<T>, int)

Validates fairness metrics for the given inputs.

Task<FairnessMetrics<T>> ValidateFairnessAsync(Tensor<T> inputs, int sensitiveFeatureIndex)

Parameters

inputs Tensor<T>

The inputs to analyze.

sensitiveFeatureIndex int

The index of the sensitive feature.

Returns

Task<FairnessMetrics<T>>

Fairness metrics results.