LabelEncoder
Compatibility: categorical data (nominal and ordinal)
The LabelEncoder transforms data that represents categorical values into integers 0, 1, 2, etc. corresponding to each category.

from rdt.transformers.categorical import LabelEncoder
le = LabelEncoder()Parameters
order_by: Apply a prescribed ordering scheme to the values before assigning the labels
(default) None
Do not apply a particular order. The first unique value will be assigned label 0, the second unique value will be assigned label 1, etc.
'numerical_value'
If the data is represented by integers or floats, order by those values before assigning the labels. That is: label 0 will be assigned to the smallest value, label 1 will be assigned to the second smallest, etc.
'alphabetical'
If the data is represented by strings, order them alphabetically before assigning the labels. That is: label 0 will be assigned to the first alphabetical string, label 1 to the second, etc. Note: Digits will also be alphabetized in order from '0' to '9'.
add_noise: Add noise to the label values
(default) False
Do not not add noise. Each time a category appears, it will always be transformed to the same label value.
True
Add noise. A category will be transformed to the same label with some noise added. For example instead of the label 1, values might be noised to 1.001, 1.456, 1.999, etc.
missing_value_encoding: Control how to encode missing values present in the categorical column.
(default) 'new_category'
Treat missing values as a new category type, just like any non-missing values. Any type of missing value (None, NaN, etc.) is treated as a single category of "missing".
None
Do not encode missing values. In this case, missing values will be kept as-is during the forward and reverse transforms.
Examples
FAQs
Last updated
