Machine LearningLesson 86Free preview
Categorical Data
This lesson is part of Python · All levels
Summary
The categorical data is text labels like color, gender, or city, and it has to be converted into numbers before it can be entered into a machine learning model. One of the techniques is one-hot encoding with pd.get_dummies() of pandas, which makes separate binary columns for each category. The label encoding changes the category to 1, 2, 3 and only matches if there is a sequence relationship. The right selection of coding techniques affects the quality of the final model.
Key points
- The categorical data is a text label and must be encoded into numbers.
- Pd.get_dummies() create a binary column per category (one-hot encoding)
- Hazardous coding labels when used in a category without a sequence
- The resulting encoding column must be consistent between the training data and the test data
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.