One-hot encoding
One-hot encoding is an often-used technique in machine learning for feature engineering. Some machine learning algorithms cannot handle categorical features, so one-hot encoding is a way to convert these categorical features into numerical features. Let's say that you have a feature labeled "status" that can take one of three values (red, green, or yellow). Because these values are categorical, there is no concept of which value is higher or lower. We could convert these values to numerical values and that would give them this characteristic. For example:
Yellow = 1
Red = 2
Green = 3
But this seems somewhat arbitrary. If we knew that red is bad and green is good, and yellow is somewhere in the middle, we might change the mapping to something like:
Red = -1
Yellow = 0
Green = 1
And that might produce better performance. But now let's see how this example can be one-hot encoded. To achieve the one-hot encoding of...