A model never sees your data — it sees a matrix of numbers.
How a column becomes those numbers is a modeling decision, not bookkeeping.
price) or discrete counts (reviews). Already numbers.color: red / green / blue).size: S < M < L).on_sale: yes / no).The type of the column decides how you're allowed to encode it.
Write a name down as a number and you invent an order it never had.
Label-encode color as blue = 0, green = 1, red = 2 and you've told the model:
None of that is true of colors. A linear model believes all of it.
One column per category, exactly one lit per row — three orthogonal axes, nothing closer to anything.
A linear model's contribution from a label integer is one weight times the code:
η=w⋅code(x)+bIts response must be monotone in the code — it cannot make the middle category an outlier. And any distance reads
code(ci)−code(cj)so 0 and 2 are twice as far apart as 0 and 1. Fine for real orders, a fabrication otherwise.
Color alone, fit two ways. Rings = true rates; diamonds = the model. Green's true rate is 0.07.
Label-encoded, green is dragged to 0.52. One-hot, it drops to 0.10. Accuracy 0.52 → 0.79.
Same table, one split, four runs. Test accuracy — fraction of held-out visitors called right (unitless, 0–1).
Linear model: 0.573 → 0.760, a 0.187 lift. Tree: 0.747 → 0.733, barely a flinch.