Skip to content
AI360Xpert
Glossary
Definition

Ordinal Encoding

Mapping ordered categories to integers that respect their order — small, medium, large becoming 0, 1, 2.

The point is that the integers carry meaning. size >= 1 selects medium and large in one comparison, which a tree finds in a single split and one-hot encoding cannot express without combining columns.

So it's the right choice whenever the order is real — sizes, severities, star ratings, education levels — and one-hot encoding there throws away the signal you had.

It's also the most common way to break a nominal column. Map forty countries to 0 through 39 and a linear model reads country 39 as thirty-nine times country 1, while a distance metric puts alphabetical neighbours close together. LabelEncoder is built for targets and lands on features constantly, because it's one line and the error message goes away.

What to Read Next