thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

AI & Machine Learning · Foundational

One-Hot Encoding

Representing a categorical variable as multiple binary columns, one per category.

Definition

Each category becomes its own 0/1 column so that models do not infer a false order among categories. It works well for low-cardinality features but creates many sparse columns for high-cardinality ones, where target encoding, hashing or embeddings are better. Label (ordinal) encoding is appropriate only when categories have a natural order.

Example

Turning color = red/green/blue into color_red, color_green and color_blue columns.

Exam tip

Use one-hot for nominal categories; use ordinal encoding only when order is meaningful (small < medium < large).

Related terms