Interface IInterpretableModel<T>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
Interface for models that support interpretability features.
public interface IInterpretableModel<T>
Type Parameters
TThe numeric type for calculations.
Methods
ConfigureFairness(Vector<int>, params FairnessMetric[])
Configures fairness evaluation settings.
void ConfigureFairness(Vector<int> sensitiveFeatures, params FairnessMetric[] fairnessMetrics)
Parameters
sensitiveFeaturesVector<int>The indices of sensitive features.
fairnessMetricsFairnessMetric[]The fairness metrics to evaluate.
EnableMethod(params InterpretationMethod[])
Enables specific interpretation methods.
void EnableMethod(params InterpretationMethod[] methods)
Parameters
methodsInterpretationMethod[]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
inputTensor<T>The input data.
predictionTensor<T>The prediction made by the model.
Returns
GetAnchorExplanationAsync(Tensor<T>, T)
Gets anchor explanation for a given input.
Task<AnchorExplanation<T>> GetAnchorExplanationAsync(Tensor<T> input, T threshold)
Parameters
inputTensor<T>The input to explain.
thresholdTThe 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
inputTensor<T>The input to analyze.
desiredOutputTensor<T>The desired output.
maxChangesintThe 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
feature1IndexintThe index of the first feature.
feature2IndexintThe 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
inputTensor<T>The input to explain.
numFeaturesintThe 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
inputTensor<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
featureIndicesVector<int>The feature indices to analyze.
gridResolutionintThe 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
inputsTensor<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
modelIFullModel<T, TInput, TOutput>The base model. Must implement IFullModel.
Type Parameters
TInputThe input type for the model.
TOutputThe 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
inputsTensor<T>The inputs to analyze.
sensitiveFeatureIndexintThe index of the sensitive feature.
Returns
- Task<FairnessMetrics<T>>
Fairness metrics results.