Articles → MACHINE LEARNING → One-Hot Encoding And Label Encoding In Machine Learning
One-Hot Encoding And Label Encoding In Machine Learning
One-Hot Encoding
- Red
- Green
- Blue
| Color | Red | Green | Blue |
|---|
| Red | 1 | 0 | 0 |
| Green | 0 | 1 | 0 |
| Blue | 0 | 0 | 1 |
Label Encoding
Difference
| One-Hot Encoding | Label Encoding |
|---|
| Creates a binary column for each category. | Sequential numbers are assigned to each category. |
| As each category is assigned either 0 or 1. So, the unique number is not assigned. | A unique number is assigned to each category. |
| The encoding is used when categories are independent of each other, like Red, Green, Blue, etc. | Creates a false sense of order among the categories like Low < Medium < High. |
| Posted By - | Karan Gupta |
| |
| Posted On - | Tuesday, October 28, 2025 |