Ordinal encoding
Ordinal encoding converts ordered categories into numeric values. It preserves the rank of each category so models can evaluate the variable in a structured way. For example, categories such as low, medium, and high can be mapped to 1, 2, and 3.
Example
Imagine a dataset with customer reviews, where one variable captures the rating given by the customer, such as poor, average, or excellent. Because these categories have a natural order, ordinal encoding can convert them into numeric values while keeping that ranking intact. In this case, poor might be encoded as 1, average as 2, and excellent as 3. This lets machine learning models process the categorical information while preserving the order of the ratings.