AI GLOSSARY · AI CONCEPTS
One-hot encoding
Definition
One-hot encoding represents each categorical feature with indicator columns, assigning 1 to its observed category and 0 to the other represented categories.
Also called: one-of-K encoding.
In plain language
One-hot encoding turns a categorical value into a binary indicator vector defined by a fixed vocabulary and order. With color vocabulary [red, blue, green], red becomes [1, 0, 0] and blue becomes [0, 1, 0]. Each categorical feature has its own vector; a row with several features can therefore contain several ones after those vectors are combined.
Technical definition
Canonical full one-hot encoding creates one indicator per represented category of each feature, with exactly one 1 in that feature’s vector for a known single-valued category. Implementations may instead drop a category, group infrequent categories or define special unknown-category behavior. An unseen value may raise an error, map to an infrequent bucket or produce all zeros, depending on explicit settings. These variants are not equivalent, and not every model requires one-hot inputs.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Use the data-analysis EDA skill before encoding to inspect category spellings, case variants, distinct values, leading-zero codes and frequent values in a CSV.
- Why it exercises the concept
- Those checks can expose accidental duplicate categories and numeric-looking codes before a vocabulary is fixed. The skill does not choose an encoding policy, implement one-hot encoding, train a model or determine how unknown and infrequent categories should be handled.
How it shows up when you use agents
One-hot encoding is useful when an agent workflow passes categorical records to a model or estimator that expects numeric features. The vocabulary and order must be explicit. Suppose color uses [red, blue] and size uses [small, large]. For a red, large item, the color feature’s indicator vector is [1, 0], while the size feature’s indicator vector is [0, 1]. Concatenating them gives [1, 0, 0, 1]. There are two ones because there are two categorical features; “one hot” applies separately to each known, single-valued feature.
Before fixing the vocabulary, inspect spelling and case. Blue, blue and blue can accidentally become separate indicators. The EDA skill can surface such variants and numeric-looking codes, but it does not perform the encoding.
Common confusions
Assigning red = 1 and blue = 2 is integer coding, not one-hot encoding. Those numbers can introduce an unintended order or distance. One-hot indicators avoid that particular implication, although they do not guarantee that the resulting features suit every model.
Full one-hot encoding and dropped-category variants differ. With full encoding, [red, blue] produces two columns. A configured drop policy might retain only the blue column, making red [0] and blue [1]. That exception should be named rather than described as canonical full one-hot encoding.
Unknown categories also require an explicit policy. If green was absent from the vocabulary [red, blue], an implementation might reject it. With a setting such as ignoring unknowns, it might produce [0, 0], which is not a standard known-category one-hot vector and can be confused with a dropped reference category. Another configuration may group it into an infrequent-category column. Record the vocabulary, column order, drop policy, grouping policy and unknown handling with the transformed data. Not all model families require or benefit from one-hot encoding.
Related terms
Terms that mention One-hot encoding
1 terms mention this one
More in AI concepts
Sources
- Machine Learning Glossary: one-hot encoding, Google for Developers (accessed 2026-11-25)
- OneHotEncoder, scikit-learn (accessed 2026-11-25)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.
Review record
Last verified
Drafted by OpenAI Codex (configured gpt-5.6-sol); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .
Change log (3)
- : Independent automated source/example and simulated-reader review closed. Cached broad US definition-query estimate; not AI-exclusive or promised traffic. Final runtime gate recorded separately; publication disabled.
- : Private source-bound draft; independent factual, reader and runtime gates pending. Cached broad US demand is not exclusively AI demand.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.