Can anyone explain one hot encoding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Can anyone explain one hot encoding

Sklearn in python

3rd Jun 2022, 6:58 AM
Winile Yvonne Makhanya
Winile Yvonne Makhanya - avatar
2 Answers
0
One hot encoding is an encoding method for categorical features. Let's say your data has a column containing 3 different values: a, b, and c. One hot encoding replaces this column with 3 new columns: 1 column for value a, 1 column for value b, one column for value c. The value in the corresponding column will be set to 1, the remaining values will be set to 0. a -> 100 b -> 010 c -> 001 This is usually necessary for models that are not based on trees, because they do not handle categorical data well. For example k-nearest-neighbors, regression, and support vector machines.
4th Jul 2022, 7:47 PM
Chris
Chris - avatar
0
Thanks but how do you implement it in sklearn? step by step code in python
5th Jul 2022, 9:57 AM
Winile Yvonne Makhanya
Winile Yvonne Makhanya - avatar