A dataset includes a categorical feature with exactly 5 possible, unordered values (e.g., shipping method). Which encoding is generally best before feeding this feature into a neural network?
Select an answer to reveal the explanation.
Short Explanation and Infographic
With only 5 unordered categories, one-hot encoding is the sweet spot. You turn that single column into 5 binary columns, each one flagging 'is it this category or not,' and none of them imply any ranking between shipping methods. That's why it's correct here — small category count, no natural order, one-hot handles it cleanly without adding false relationships. Leaving raw text strings won't work at all; neural nets need numbers, not words, to do their math. Min-max normalization is for continuous numeric ranges, not discrete labels — there's no meaningful 'minimum' or 'maximum' shipping method. And assigning arbitrary integer ranks is dangerous because it invents an order that doesn't exist — the network might learn that 'method 3' is somehow greater than 'method 1,' which is nonsense for unordered categories.
Full explanation below image
Full Explanation
One-hot encoding is the standard and generally best choice for a categorical feature with a small number of unordered categories, such as 5 shipping methods. It represents each category as a binary vector where exactly one position is 1 (indicating the active category) and all others are 0. This avoids implying any ordinal relationship or numeric distance between categories, which is critical because shipping methods (or similarly unordered categories like colors or product types) have no inherent ranking — 'Method A' is not mathematically 'less than' or 'greater than' 'Method B.' With only 5 categories, the resulting dimensionality increase (5 new binary columns replacing 1 original column) is modest and computationally inexpensive, making one-hot encoding both correct and practical here.
Leaving the categories as raw text strings is not viable because neural networks operate on numeric tensors; text values cannot be passed directly into matrix multiplications or other numeric operations that make up a network's forward pass. Some encoding step is always required before raw categorical text can reach a model.
Applying min-max normalization to category labels is a misuse of a technique designed for continuous numeric features. Even if categories were superficially assigned numbers, min-max scaling would rescale those arbitrary numeric labels into a range like [0, 1], which does not resolve the fundamental problem: the numeric labels still carry no meaningful magnitude or order for unordered categories, and scaling them further compounds the confusion rather than fixing it.
Assigning arbitrary integer ranks (ordinal/label encoding) is problematic for unordered categorical data because it introduces a false sense of order and distance between categories that the model may inadvertently learn as meaningful (e.g., treating category 4 as 'twice as much' as category 2). Ordinal/label encoding is appropriate only when categories have a genuine, meaningful order (such as 'low,' 'medium,' 'high'), which is not the case for something like shipping method.
Memory aid: use one-hot encoding for unordered ('nominal') categories, especially with a small number of categories, and reserve ordinal/label encoding for categories with a true rank order. As category cardinality grows very large, alternatives like embeddings become preferable to avoid excessive dimensionality, but for 5 categories one-hot remains the clean, standard choice.