Abstract base class for counterfactual explanation methods.
Child classes: CounterfactualMethodClassif, CounterfactualMethodRegr
new()Creates a new CounterfactualMethod object.
CounterfactualMethod$new(
predictor,
lower = NULL,
upper = NULL,
distance_function = NULL
)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.
print()Prints a CounterfactualMethod object.
The method calls a (private) $print_parameters() method which should be implemented by the leaf classes.
CounterfactualMethod$print()
clone()The objects of this class are cloneable with this method.
CounterfactualMethod$clone(deep = FALSE)deepWhether to make a deep clone.