Blog/Categorical Encoding

Preprocessing

Categorical Encoding

One-hot, label, and target encoding

SK

Skari Team

Skari

July 2026·8 min read

One-Hot Encoding

A categorical column becomes one 0/1 column per category — numbers a model can use.

ABCAABC100010001100

Most models only understand numbers, but real data is full of categories: city, plan tier, device type. Encoding converts those categories into numeric columns — and the method you pick changes what the model can learn from them.

Note

The danger isn't converting to numbers — it's converting in a way that invents an order that doesn't exist, or one that quietly leaks the target.

The Three Main Methods

MethodWhat it does
One-hotOne 0/1 column per category — no false order
LabelEach category → an integer — implies an order
TargetCategory → its mean target value — powerful but leaks easily

One-hot, shown in the diagram above, is the safe default for nominal categories — it never implies that C is greater than A.

When Each Fits

  • One-hot: nominal categories with few distinct values
  • Label: genuinely ordinal categories (small < medium < large)
  • Target: high-cardinality features — but only with careful cross-validation

Watch out

Never use label encoding on nominal data. Assigning Seoul = 1, Busan = 2, Incheon = 3 tells the model Incheon is 'three times' Seoul — a relationship that doesn't exist.

The High-Cardinality Trap

One-hot encoding a column with hundreds of categories explodes it into hundreds of sparse columns. For high-cardinality features, group rare categories into "other," or use target encoding — carefully, because it can leak the answer.

Watch out

Target encoding computed on the whole dataset leaks the target into training. Compute it inside cross-validation folds, or you'll overstate your model's accuracy.

Encoding in the SKARI Data Editor

The Data Editor's encoding tool converts categorical columns without code: pick a column and a method, preview the new columns, and apply it as a tracked step in your preprocessing pipeline.

  • One-hot and label encoding on any categorical column
  • A preview of the resulting columns before you commit
  • Every step recorded in the pipeline history, so it's reproducible

Takeaway

You see exactly what each category becomes — and the step stays in your pipeline, not buried in a script.

Frequently Asked Questions

One-hot or label?

One-hot for nominal categories; label only when the categories have a real order.

Do tree models need one-hot?

Less so — trees can split on label-encoded values, but one-hot is still safer for nominal data and required for linear models.

When is target encoding worth it?

For high-cardinality features where one-hot explodes — but only computed within cross-validation to avoid leakage.

Conclusion

Encoding is where text becomes something a model can learn from. Match the method to the category type, watch cardinality, and guard against leakage — and your features carry real signal, not a fabricated order.

Takeaway

Turn categories into numbers without inventing an order — one-hot when in doubt, and leakage-safe target encoding only when you need it.

Feature Engineering

What to build once it's numeric

Data Normalization

Scaling the numbers you just made

Cross-Validation

Where target encoding must live