explainer.base#

This module gathers base Explanation Methods

Classes

BaseIncrementalExplainer(model_function, ...)

Base class for incremental explainer algorithms.

BaseIncrementalFeatureImportance(...[, ...])

Base class for incremental feature importance explainer algorithms.

class explainer.base.BaseIncrementalExplainer(model_function, feature_names)[source]#

Bases: object

Base class for incremental explainer algorithms.

Warning: This class should not be used directly. Use derived classes instead.

Parameters:
  • model_function (Callable) – The Model function to be explained.

  • feature_names (list) – List of feature names to be explained for the model.

feature_names#

List of feature names that are explained.

Type:

list[Any]

number_of_features#

Number of features that are explained.

Type:

int

seen_samples#

Number of instances observed.

Type:

int

class explainer.base.BaseIncrementalFeatureImportance(model_function, loss_function, feature_names, storage=None, imputer=None, dynamic_setting=False, smoothing_alpha=None)[source]#

Bases: BaseIncrementalExplainer

Base class for incremental feature importance explainer algorithms.

Warning: This class should not be used directly. Use derived classes instead.

abstract explain_one(*args, **kwargs)[source]#
get_confidence_bound(delta)[source]#

Calculates Delta-Confidence Bounds.

Parameters:

delta (float) – The confidence parameter. Must be a value in the interval of ]0,1].

Returns:

The upper confidence bound around the point estimate of the importance values.

This value needs to be added to the top and bottom of the point estimate.

Return type:

(dict)

get_normalized_importance_values(mode='sum')[source]#

Normalizes the importance scores.

Parameters:
  • mode (str) – The normalization mode to be applied. Possible values are ‘sum’ and ‘delta’.

  • 'sum'. (Defaults to) –

    • sum: Normalizes the importance scores by division through the sum of importance scores.

    • delta: Normalizes the importance scores by division through the difference between the max of the

    importance scores and the min of the importance scores.

Returns:

The normalized importance values.

Return type:

(dict)

update_storage(x_i, y_i=None)[source]#

Manually updates the data storage with the given observation. :type x_i: dict :param x_i: The input features of the current observation. :type x_i: dict :type y_i: Optional[Any] :param y_i: Target label of the current observation. Defaults to None :type y_i: Any, optional

property importance_values#

Incremental Importance Values property.

property variances#

Incremental Variances values property.