Explaination Service User Manual with Alibi Anchors
Introduction
This service lets to generate local explainantions for tabular classification models using the AnchorTabular method of the alibi-explain library. The service is planned to work with scikit-learn interface compatible models and with tabular datasets.
Service Features
- Generation of rule-based (anchor) interpretable explanations for model predictions.
- Support for scikit-learn models or compatible with
predictmethod. - Customization possibility for explainer behaviour and
fitfunction. - Automatic handling of numerical and categorical features, including percentile-based discretization.
Parameters
The service accepts the folloing parameters:
--labelCol: (mandatory) namen of target column.--disc_perc: (optional) percentiles for discretization, i.e.(25,50,75)(default).--direct_args_to_explainer: JSON dictionary with arguments to pass toAnchorTabularconstructor direclty. Check for official documentation for all available parameters: https://docs.seldon.io/projects/alibi/en/latest/api/alibi.explainers.html#alibi.explainers.AnchorTabular--direct_args_to_explainer_fit_function: JSON dictionary with arguments to pass da passare directly to explainer.fit()method. Available parametri are descripted here: https://docs.seldon.io/projects/alibi/en/latest/api/alibi.explainers.html#alibi.explainers.AnchorTabular.fit
Input and Output
Input
- Tabular Dataset: must be provided in
pandas.DataFrameformat or equal. -
Input Modello: a compatible classificator with
scikit-learninterface. It must: -
implement the
.predict()method; - return discreet labels (not probability);
- have the
feature_names_in_attribute (tipically available if trained with a Pandas DataFrame). The model have to be: - a
scikit-learnclassificator (i.e.RandomForestClassifier,LogisticRegression, etc.); - a scikit-learn pipeline;
- a libreries models scikit-learn compatible (i.e.
XGBoost,LightGBM,CatBoost) as long as they have teh same interface. The models generated bysklearntraining service, already present on the Data Analytics System platform, are surely compatible.
Output
- Saved Explainer: a model
alibi-explainin the Data Analytics System supported format, containing both the trained explainer and model to be eplained.
Use Sample
To use the service, it0s enough to configure the requested parameters and load the needed files using the Data Analytics System interface. Here below a practical example:
Setting Example
- Dataset di input:
credit_default.csv - Modello di input:
random_forest_credit.pkl(trained with sklearn servizio in the Data Analytics System) - Parameters:
{
"labelCol": "default",
"disc_perc": "(25,50,75)",
"direct_args_to_explainer": {
"batch_size": 100
},
"direct_args_to_explainer_fit_function": {
"beam_size": 10
}
}
Once you'll configure these elements, it's enough to save and start the BDA application (workflow). The serveice will return a alibi-explain model which it will be possible to generate local prediction explanations.