scoring_explainer Package

Defines scoring models for approximating feature importance values.

Classes

DeepScoringExplainer

Defines a scoring model based on DeepExplainer.

If the original explainer was using a SHAP DeepExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Initialize the DeepScoringExplainer.

If the original explainer was using a SHAP DeepExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

KernelScoringExplainer

Defines a scoring model based on KernelExplainer.

If the original explainer was using a SHAP KernelExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Initialize the KernelScoringExplainer.

If the original explainer was using a SHAP KernelExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

LinearScoringExplainer

Defines a scoring model based on LinearExplainer.

If the original explainer was using a SHAP LinearExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Initialize the LinearScoringExplainer.

If the original explainer was using a SHAP LinearExplainer and no initialization data was passed in, the core of the original explainer will be reused. If the original explainer used another method or new initialization data was passed in under initialization_examples, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

ScoringExplainer

Defines a scoring model.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expect transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Initialize the ScoringExplainer.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expect transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

TreeScoringExplainer

Defines a scoring model based on TreeExplainer.

If the original explainer was using a SHAP TreeExplainer, the core of the original explainer will be reused. If the original explainer used another method, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Initialize the TreeScoringExplainer.

If the original explainer was using a SHAP TreeExplainer, the core of the original explainer will be reused. If the original explainer used another method, a new explainer will be created.

If transformations was passed in on original_explainer, those transformations will be carried through to the scoring explainer, it will expect raw data, and by default importances will be returned for raw features. If feature_maps are passed in here (NOT intended to be used at the same time as transformations), the explainer will expected transformed data, and by default importances will be returned for transformed data. In either case, the output can be specified by setting get_raw explicitly to True or False on the explainer's explain method.

Functions

load

Load the scoring explainer from disk.

load(directory)

Parameters

Name Description
directory
Required
str

The directory under which the serialized explainer is stored. Assumes that scoring_explainer.pkl is available at the top level of the directory.

Returns

Type Description

The scoring explainer from an explanation, loaded from disk.

save

Save the scoring explainer to disk.

save(scoring_explainer, directory='.', exist_ok=False)

Parameters

Name Description
scoring_explainer
Required

The scoring explainer object which is to be saved. The explainer will be written out to [directory]/scoring_explainer.pkl.

directory
str

The directory under which the serialized explainer should be stored. If the directory doesn't exist, it will be created.

default value: .
exist_ok

If False (the default state), a warning will be thrown if the directory given already exists. If True, the current directory will be used and any overlapping contents will be overwritten.

default value: False

Returns

Type Description
str

The path to the scoring explainer pickle file.