| .guard_ensure_levels | R Documentation |
Converts character/logical columns to factors and aligns factor levels with
a training-time levels_map. Adds a dummy level when a column has only
one observed level so that downstream one-hot encoding retains a column.
.guard_ensure_levels(df, levels_map = NULL, dummy_prefix = "__dummy__")
df |
data.frame to normalize factor levels. |
levels_map |
optional named list of factor levels learned from training data. |
dummy_prefix |
prefix used when adding a dummy level to single-level factors. |
List with elements data (data.frame) and levels (named list of levels).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.