One-hot Encoding

Solomon Xie
Machine Learning Study Notes
2 min readJan 8, 2019

--

Refer to Quora: What is one-hot encoding and when is it used in data science?
Refer to youtube: A demo of One Hot Encoding (TensorFlow Tip of the Week)

“Encoding” is to take a number to represent a categorical value.

Lable encoding:

But the problem is, those values would rather be nominal values instead of ordinal values, because we can’t say one is greater or smaller than another.
And there it comes One-hot encoding, which we only take numbers 1 & 0 to represent the categorical value, but in a TABLE:

Note that, the the result of encoding will be as a VECTOR.

In this case, the value for sample-1 is encoded to a vector [1,0,0,0], and value of sample-5 is encoded to vector [0,0,0,1].

-

--

--

Solomon Xie
Machine Learning Study Notes

Jesus follower, Yankees fan, Casual Geek, Otaku, NFS Racer.