Extracts and formats the training and/or target datasets from a machine learning model trained with caret::train,
allowing for distinction between using the full training data or only the original subset used for modeling.
It standardizes the class column to be named "class_efficiency" and positions it as the last column.
xai_prepare_sets(
data,
x,
y,
final_model,
background,
target,
type,
threshold,
levels_order
)A list with two elements:
train_dataA data.frame representing the background dataset, with the class column renamed to "class_efficiency" and positioned last.
target_dataA data.frame representing the target dataset, formatted in the same way.
A data.frame containing the original dataset used to train the model. Only needed when using "real" as background or target.
Not currently used. Reserved for future input variable selection.
Not currently used. Reserved for future output variable specification.
A trained model object of class "train" from the caret package.
A character string, either "train" or "real", specifying the background dataset used for explainability.
A character string, either "train" or "real", specifying the target dataset to be explained.
Not currently used. Reserved for future prediction types.
Not currently used. Reserved for future thresholding logic.
A character vector specifying the levels of the response factor, typically c("not_efficient", "efficient"). Not currently used, but can help in reordering or relabeling.