Converting a category column to a boolean indicator matrix — one column per sorted unique category.

highlighted = computed this step

Input column

The raw category column — each entry is a color label.

input column\text{input column}
Input columninputredblueredgreen

One-hot matrix

Sorted unique categories become column names. Each row marks its category with one, all others with zero.

one-hot matrix\text{one-hot matrix}
One-Hot Matrixinputbluegreenredred001blue100red001green010