Learn R Programming

autotab (version 0.1.2)

feat_reorder: Reorder feat_dist rows to match preprocessed data

Description

Ensures row order in feat_dist matches the column prefix order in the preprocessed (dummy-coded) training data. This assumes dummy columns are named as <original_name>_<level> and therefore start with the original variable name.

Usage

feat_reorder(feat_dist, data)

Value

The input feat_dist, reordered to align with data.

Arguments

feat_dist

Data frame from extracting_distribution().

data

Data frame of the original (not preprocessed) variables.

See Also

extracting_distribution(), set_feat_dist()

Examples

Run this code
# Small toy dataset
data_example <- data.frame(
  cont = rnorm(5),
  bin  = c(0, 1, 0, 1, 1),
  cat  = factor(c("A", "B", "C", "A", "C"))
)

# Extract feature distributions in original column order
feat_dist <- extracting_distribution(data_example)

# Suppose preprocessing (e.g., dummy coding) reordered the columns
data_reordered <- data_example[, c("cat", "cont", "bin")]

# Reorder feat_dist rows to match the preprocessed data columns
feat_dist_reordered <- feat_reorder(feat_dist, data_reordered)
feat_dist_reordered

Run the code above in your browser using DataLab