wildboar.explain.counterfactual._sf#

Module Contents#

Classes#

PredictionPaths

ShapeletForestCounterfactual

Counterfactual explanations for shapelet forest classifiers

class wildboar.explain.counterfactual._sf.PredictionPaths(classes)[source]#
__contains__(item)[source]#
__getitem__(item)[source]#
prune(max_paths, random_state)[source]#
class wildboar.explain.counterfactual._sf.ShapeletForestCounterfactual(*, cost='euclidean', aggregation='mean', epsilon=1.0, batch_size=0.1, max_paths=1.0, verbose=False, random_state=None)[source]#

Bases: wildboar.base.CounterfactualMixin, wildboar.base.ExplainerMixin, wildboar.base.BaseEstimator

Counterfactual explanations for shapelet forest classifiers

paths_[source]#

A dictionary of prediction paths per label

Type:

dict

Notes

This implementation only supports the reversible algorithm described by Karlsson (2020)

Warning

Only shapelet forests fit with the Euclidean distance is supported i.e., metric="euclidean"

References

Karlsson, I., Rebane, J., Papapetrou, P., & Gionis, A. (2020).

Locally and globally explainable time series tweaking. Knowledge and Information Systems, 62(5), 1671-1700.

Karlsson, I., Rebane, J., Papapetrou, P., & Gionis, A. (2018).

Explainable time series tweaking via irreversible and reversible temporal transformations. In 2018 IEEE International Conference on Data Mining (ICDM)

Parameters:
  • cost ({"euclidean", "cosine", "manhattan"}, optional) – The cost function to determine the goodness of counterfactual

  • aggregation (callable, optional) – The aggregation function for the cost of multivariate counterfactuals.

  • epsilon (float, optional) – Control the degree of change from the decision threshold

  • batch_size (float, optional) –

    Batch size when evaluating the cost and predictions of counterfactual candidates. The default setting is to evaluate all counterfactual samples.

    Changed in version 1.1: The default value changed to 0.1

  • max_paths (float, optional) –

    Sample a fraction of the positive prediction paths.

    New in version 1.1: Add support for subsampling prediction paths.

  • verbose (boolean, optional) – Print information to stdout during execution.

  • random_state (RandomState or int, optional) – Pseudo-random number for consistency between different runs

explain(x, y)[source]#
fit(estimator, x=None, y=None)[source]#