Overview of alibi.explainers
masteralibi.explainers module provides various methods for model interpretability, including feature importance, counterfactual explanations, and anchor-based explainers.repository·master·Indexed 25 days ago
https://github.com/seldonio/alibiA Python library for machine learning model inspection and interpretation. Alibi provides implementations of black-box, white-box, local, and global explanation methods for classification and regression models, including ALE, Anchors, Integrated Gradients, and SHAP. It also includes modules for assessing model confidence via Trust Scores and finding representative dataset instances using ProtoSelect.
alibi.explainers module provides various methods for model interpretability, including feature importance, counterfactual explanations, and anchor-based explainers.The Anchors algorithm provides model-agnostic, high-precision, human-interpretable explanations for classification models applied to text, tabular, and image data. Unlike LIME, which uses linear proxies, Anchors find 'if-then' rules (anchors) that are locally sufficient to guarantee a prediction with high confidence.
Key concepts:
threshold for this.AND (e.g., Age < 30 AND Occupation = Engineer).Alibi Explain is a source-available Python library designed for machine learning model inspection and interpretation. It provides high-quality implementations of various explanation methods, including:
Alibi provides various algorithms for explaining machine learning model predictions. These are categorized into two main types:
| Method | Model Type | Explanation Type | Supported Data/Tasks |
|---|---|---|---|
| ALE | BB | Global | Tabular (Numerical) |
| Partial Dependence | BB, WB | Global | Tabular (Num/Cat), Class/Reg |
| PD Variance | BB, WB | Global | Tabular (Num/Cat), Class/Reg |
| Permutation Importance | BB | Global | Tabular (Num/Cat), Class/Reg |
| Anchors | BB | Local | Tabular, Text, Image, Class |
| CEM | BB* (Differentiable), TF/Keras | Local | Tabular, Image, Class |
| Counterfactuals | BB* (Differentiable), TF/Keras | Local | Tabular, Image, Class |
| Prototype Counterfactuals | BB* (Differentiable), TF/Keras | Local | Tabular, Image, Class |
| Counterfactuals with RL | BB | Local | Tabular, Image, Class |
| Integrated Gradients | TF/Keras | Local | Tabular, Text, Image, Class/Reg |
| Kernel SHAP | BB | Local & Global | Tabular (Num/Cat), Class/Reg |
| Tree SHAP | WB | Local & Global | Tabular (Num/Cat), Class/Reg |
| Similarity explanations | WB | Local | Tabular, Text, Image, Class/Reg |
Key Definitions:
Counterfactuals are local explanations that identify the minimal changes required to an input instance to achieve a different model prediction. They are used to debug model functionality or provide actionable insights (e.g., how a customer could change their behavior to receive a different financial decision).
Alibi provides four main methods for generating counterfactuals:
fit, slow explain. Best for simple tabular or grayscale image data.fit, fast explain. This is the preferred method for multi-channel images and production environments requiring high performance.Insights provided by Alibi are categorized by their scope:
Alibi provides Permutation Importance to measure global feature importance by calculating the degree of model performance degradation when feature values in a column are permuted.
Use Case: Identifying which features are most important globally for Tabular data (numerical and categorical) in Classification or Regression tasks.
Pros:
Cons:
Beyond standard explanations, Alibi Explain provides modules for:
Alibi provides algorithms to generate instance-specific scores that measure how confident a model is in its specific prediction.
Supported methods:
Trust Scores: Produces a score representing the ratio between the distance to the nearest class different from the predicted class and the distance to the predicted class. Higher scores indicate more trustworthy predictions.
Linearity Measure: Produces a score quantifying how linear the model behaves around a specific test instance. It works by feeding the model linear superpositions of inputs and comparing the outputs against the linear combination of outputs from single-input predictions.
Similarity explanations are instance-based local explanations. They justify a model's prediction by identifying the most similar instances in the training set that share the same prediction.
Key Characteristics: