Ordinal encoding

A metamorphosis of subtle hierarchy, ordinal encoding transforms categorical variables into numerical values, like a series of stepping stones across a river, preserving the inherent order of the categories and enabling machine learning models to recognize and analyze the relationships within the dataset.

Example

Imagine a dataset containing information about customer reviews, with a categorical variable representing the rating given by the customer (e.g., 'poor', 'average', or 'excellent'). Since these categories have a natural order, ordinal encoding can be used to convert them into numerical values while maintaining their relative ranking. In this case, 'poor' might be encoded as 1, 'average' as 2, and 'excellent' as 3. This transformation allows machine learning models to process and learn from the categorical information while preserving the inherent order of the ratings.