Caesar AI Atlas

One-hot Encoding

Also known as: One hot Encoding

Caesar AI Atlas Definition

One-hot encoding represents a categorical value as a vector in which one element is set to 1 and all others are set to 0. It lets models distinguish categories without incorrectly treating them as ordered numerical quantities.

Other Definitions

One-hot Encoding Source

Representing categorical data as a vector in which: - One element is set to 1. - All other elements are set to 0. One-hot encoding is commonly used to represent strings or identifiers that have a finite set of possible values. For example, suppose a certain categorical feature named has five possible values: - "Denmark" - "Sweden" - "Norway" - "Finland" - "Iceland" One-hot encoding could represent each of the five values as follows: Vector | ---------| 1 0 0 | 0 0 0 | 0 1 0 | 0 0 0 | 0 0 1 | Thanks to one-hot encoding, a model can learn different connections based on each of the five countries. Representing a feature as numerical data is an alternative to one-hot encoding. Unfortunately, representing the Scandinavian countries numerically is not a good choice. For example, consider the following numeric representation: - "Denmark" is 0 - "Sweden" is 1 - "Norway" is 2 - "Finland" is 3 - "Iceland" is 4 With numeric encoding, a model would interpret the raw numbers mathematically and would try to train on those numbers. However, Iceland isn't actually twice as much (or half as much) of something as Norway, so the model would come to some strange conclusions. See Categorical data: Vocabulary and one-hot encoding in Machine Learning Crash Course for more information.

One-hot Encoding Source

One-hot encoding represents each category as a vector of N elements (where N is the number of categories) with exactly one element having a value of 1.0 and all remaining elements having a value of 0.0. For more information, see One-hot encoding.

Related Terms