Abstract base class for counterfactual explanation methods.

Methods


Method new()

Creates a new CounterfactualMethod object.

Usage

CounterfactualMethod$new(
  predictor,
  lower = NULL,
  upper = NULL,
  distance_function = NULL
)

Arguments

predictor

(Predictor)
The object (created with iml::Predictor$new()) holding the machine learning model and the data.

lower

(numeric() | NULL)
Vector of minimum values for numeric features. If NULL (default), the element for each numeric feature in lower is taken as its minimum value in predictor$data$X. If not NULL, it should be named with the corresponding feature names.

upper

(numeric() | NULL)
Vector of maximum values for numeric features. If NULL (default), the element for each numeric feature in upper is taken as its maximum value in predictor$data$X. If not NULL, it should be named with the corresponding feature names.

distance_function

(character(1) | function())
Either the name of an already implemented distance function (currently 'gower' or 'gower_c') or a function having three arguments: x, y, and data. The function should return a double matrix with nrow(x) rows and maximum nrow(y) columns.


Method print()

Prints a CounterfactualMethod object. The method calls a (private) $print_parameters() method which should be implemented by the leaf classes.

Usage

CounterfactualMethod$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

CounterfactualMethod$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.