Data Preparation · Flagship experience

Categorical Encoding

How do categories become numbers without inventing false meaning?

Start here

How do categories become numbers without inventing false meaning?

Models need numerical representations, but the encoding determines what relationships the model can infer. One-hot preserves nominal identity; ordinal encoding intentionally imposes order.

Building interactive view…
Understand

Build the mental model

Models need numerical representations, but the encoding determines what relationships the model can infer. One-hot preserves nominal identity; ordinal encoding intentionally imposes order. Choose encoding from semantics and model family. Never let target-derived encodings see validation labels.

Click a stage to inspect what happens, what changes, and what should be checked before moving on.
Stage 1

Categories

For the “Categories” stage, identify the incoming object, the rule applied to it, the state change produced, and the evidence that would reveal a mistake. Technical context for Categorical Encoding: One-hot creates indicator columns; ordinal maps ordered levels; target encoding uses outcome statistics and therefore requires strict out-of-fold handling.

Practitioner checkpoint: Choose encoding from semantics and model family. Never let target-derived encodings see validation labels.
What happens if…?

Break the assumption deliberately

Assign arbitrary integers to unordered cities and observe the artificial order you created.

Move the control and explain what you expect before reading the visual.

Technical lens

Formalise what the visual is doing

One-hot creates indicator columns; ordinal maps ordered levels; target encoding uses outcome statistics and therefore requires strict out-of-fold handling.

Technical questionUse a tiny case to make the mechanism observable. One-hot creates indicator columns; ordinal maps ordered levels; target encoding uses outcome statistics and therefore requires strict out-of-fold handling. Verify one intermediate quantity, state change or mapping independently; then predict the consequence of this change: Assign arbitrary integers to unordered cities and observe the artificial order you created.
Practitioner lens

Use it responsibly

Choose encoding from semantics and model family. Never let target-derived encodings see validation labels.

Transfer testScaling before cross-validation.
Worked exploration

Use the visual as an experiment, not decoration

Encode colour = {red, blue, green} as 0,1,2 and ask whether “green is twice blue” makes sense. Then one-hot encode the categories and inspect how the representation avoids invented numeric distance.

Technical lens

One-hot creates indicator columns; ordinal maps ordered levels; target encoding uses outcome statistics and therefore requires strict out-of-fold handling.

Practitioner check

Choose encoding from semantics and model family. Never let target-derived encodings see validation labels.

Prediction before interaction
Assign arbitrary integers to unordered cities and observe the artificial order you created.
Exploration walkthrough

Turn the interaction into an evidence trail

Encode colour = {red, blue, green} as 0,1,2 and ask whether “green is twice blue” makes sense. Then one-hot encode the categories and inspect how the representation avoids invented numeric distance. Before moving the control, state your prediction. After the visual changes, name the specific state, statistic, boundary or mapping that changed and explain why that change is consistent—or inconsistent—with your prediction.

  • Record one observable quantity before the interaction and the same quantity afterwards.
  • Change one factor at a time so the causal effect of the control is inspectable.
  • Use an edge or failure case to discover where the concept stops behaving as the simple story suggests.
Visual demonstration of Categorical Encoding
Static orientation diagram for Categorical Encoding; use the interactive visual above to test how the relationships change.
Reference depth

Open the complete material

The flagship experience is the map. These pages contain the roads.

Continue this exact concept

Choose depth, practice or application.

These destinations are explicitly mapped to Categorical Encoding; they are not generic landing-page fallbacks.