Uses DALEX ceteris-paribus profiles (`predict_profile`) to compute counterfactual-style what-if explanations for a given observation.
counterfactual_explain(
object,
observation,
variables = NULL,
data = c("train", "test"),
positive_class = NULL,
event_class = NULL,
label_levels = NULL,
...
)A list (returned invisibly) containing the DALEX profile, filtered lines/points when `positive_class` is supplied, and the plotted object if rendering succeeds.
A `fastml` object.
A single observation (data frame with one row) to compute counterfactuals for.
Optional character vector of candidate variables to vary. Only numeric variables are used for counterfactual profiling.
Character string specifying which data to use for the explainer background:
"train" (default) or "test".
Optional string used to filter lines/points in the resulting profiles for classification tasks.
Optional event class indicator propagated from `fastml_prepare_explainer_inputs()` (kept for compatibility).
Optional vector of label levels propagated from `fastml_prepare_explainer_inputs()` (kept for compatibility).
Additional arguments passed to `DALEX::predict_profile`.