Description Usage Arguments Value
Re-encodes categorical data as its frequency in the dataset. Useful for gradient boosting.
Does NOT return dataset, but an object that can be applied to a dataset with the applyEncoding
function.
If your data contains missing values, be very careful with the encodeNA
and allowNewLevels
parameters.
1 | frequencyEncode(dt, vars, encodeNA = FALSE, allowNewLevels = FALSE)
|
dt |
data.frame(table) to create the object on |
vars |
vector of variables you want to frequency-encode |
encodeNA |
Boolean. Should NAs be encodes as a frequency, or kept as NA when the transformation is applied? If there are no NAs in your original data, new NAs will still be encoded as 1. Risky, but easy. |
allowNewLevels |
Should any new levels be encoded as -1? Details:
|
Frequency Encoded Object. This needs to be applied to a dataset, it will not actually return a dataset.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.