Skip to content

COMTE

COMTECF(model, data, backend, mode, method='opt', number_distractors=2, max_attempts=1000, max_iter=1000, silent=False)

Bases: CF

Calculates and Visualizes Counterfactuals for Multivariate Time Series in accordance to the paper [1].

References

[1] Ates, Emre, et al. "Counterfactual Explanations for Multivariate Time Series." 2021 International Conference on Applied Artificial Intelligence (ICAPAI). IEEE, 2021.


PARAMETER DESCRIPTION
model

Model to be interpreted.

TYPE: [Module, Callable, model]

ref

Reference Dataset as Tuple (x,y).

TYPE: Tuple

backend

desired Model Backend ('PYT', 'TF', 'SK').

TYPE: str

mode

Name of second dimension: time -> (-1, time, feature) or feat -> (-1, feature, time)

TYPE: str

method

'opt' if optimized calculation, 'brute' for Brute Force

TYPE: str DEFAULT: 'opt'

number_distractors

number of distractore to be used

TYPE: int DEFAULT: 2

silent

logging.

TYPE: bool DEFAULT: False

explain(x, orig_class=None, target=None)

Calculates the Counterfactual according to Ates. Arguments: x (np.array): The instance to explain. Shape : mode = time -> (1,time, feat) or mode = time -> (1,feat, time) target int: target class. If no target class is given, the class with the secon heighest classification probability is selected.

RETURNS DESCRIPTION
([array], int)

Tuple of Counterfactual and Label. Shape of CF : mode = time -> (time, feat) or mode = time -> (feat, time)