mlr (version 2.9)

createDummyFeatures: Generate dummy variables for factor features.


Replace all factor features with their dummy variables. Internally model.matrix is used. Non factor features will be left untouched and passed to the result.


createDummyFeatures(obj, target = character(0L), method = "1-of-n", cols = NULL)


[data.frame | Task] Input data.
[character(1) | character(2) | character(n.classes)] Name(s) of the target variable(s). Only used when obj is a data.frame, otherwise ignored. If survival analysis is applicable, these are the names of the survival time and event columns, so it has length 2. For multilabel classification these are the names of logical columns that indicate whether a class label is present and the number of target variables corresponds to the number of classes.
[character(1)] Available are: “1-of-n”: For n factor levels there will be n dummy variables. “reference”: There will be n-1 dummy variables leaving out the first factor level of each variable.
[character] Columns to create dummy features for. Default is to use all columns.


[data.frame | Task]. Same type as obj.

See Also

Other eda_and_preprocess: capLargeValues, dropFeatures, mergeSmallFactorLevels, normalizeFeatures, removeConstantFeatures, summarizeColumns