OrderedLabelEncoder
Compatibility: categorical data (ordinal)
The OrderedLabelEncoder transforms data that represents ordered categorical values into integers 0, 1, 2, etc. corresponding to each category in the correct order.

from rdt.transformers.categorical import OrderedLabelEncoder
ole = OrderedLabelEncoder(order=['strongly_disagree', 'disagree', 'neutral',
'agree', 'strongly_agree'])Parameters
(required) order: Apply a specific order to the values before assigning the labels
[list <value>]
An ordered list of the categories that appear in the real data. The first category in the list will be assigned a label of 0, the second will be assigned 1, etc. All possible categories must be defined in this list.
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. In this case, it's ok if missing values don't appear in the order parameter; if they do, they will be ignored.
Examples
FAQs
Last updated
