Learn R Programming

PEAXAI (version 0.1.0)

xai_prepare_sets: Prepare Training and Target Datasets from a caret Model

Description

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.

Usage

xai_prepare_sets(
  data,
  x,
  y,
  final_model,
  background,
  target,
  type,
  threshold,
  levels_order
)

Value

A list with two elements:

train_data

A data.frame representing the background dataset, with the class column renamed to "class_efficiency" and positioned last.

target_data

A data.frame representing the target dataset, formatted in the same way.

Arguments

data

A data.frame containing the original dataset used to train the model. Only needed when using "real" as background or target.

x

Not currently used. Reserved for future input variable selection.

y

Not currently used. Reserved for future output variable specification.

final_model

A trained model object of class "train" from the caret package.

background

A character string, either "train" or "real", specifying the background dataset used for explainability.

target

A character string, either "train" or "real", specifying the target dataset to be explained.

type

Not currently used. Reserved for future prediction types.

threshold

Not currently used. Reserved for future thresholding logic.

levels_order

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.