Categorical Data Encoding
AI and machine learning models can only understand numbers.
However, much of the data we work with is text-based.
This kind of data, grouped into categories without numerical meaning, is called categorical data.`
| ID | Color | Region | Occupation | |-----|-------|--------|------------| | 1 | Red | New York | Student | | 2 | Blue | Chicago | Employee | | 3 | Green | Los Angeles | Student | | 4 | Yellow| New York | Doctor |
In the data above, color, region, and occupation are categorical data.
These cannot be used for direct calculations, and comparing their magnitude or order is not meaningful.
Categorical data can be divided into two main types.
Nominal Data
This is categorical data without any order. Examples of nominal data include colors (red, blue, green) and regions (New York, Chicago, Los Angeles).
Ordinal Data
This is categorical data with an order. Examples of ordinal data include education levels (elementary, middle, high school) and customer satisfaction levels (low, medium, high).
Categorical data needs to be converted into numerical form for machine learning, a process known as encoding.
What is Data Encoding?
Categorical data must be transformed into numbers so that machine learning models can comprehend it. This transformation process is known as data encoding.
For example, let's convert the color data above into numbers.
| ID | Color | Color (Encoded) | |-----|--------|----------------| | 1 | Red | 0 | | 2 | Blue | 1 | | 3 | Green | 2 | | 4 | Yellow | 3 |
This allows the model to process color data numerically.
There are methods like Label Encoding and One-Hot Encoding for this transformation.
We will discuss each method in more detail in the following lessons.
Lessons in this chapter · Essential Knowledge for Understanding Machine Learning
- 1. The Essential Ingredient for Training AI: Datasets
- 2. Data File Formats Used in AI Training
- 3. Preprocessing: Preparing Data for AI
- 4. Handling Missing Data with Python
- 5. Multiple Choice Quiz
- 6. Normalization: Adjusting the Scale of Data
- 7. Standardization: Matching Data Scales
- 8. Normalization vs. Standardization: When to Use Which?
- 9. Encoding Categorical Data
- 10. Label Encoding vs. One-Hot Encoding
- 11. Fill-in-the-Blank Quiz
- 12. What Are Features in Machine Learning?
- 13. Feature Selection and Dimensionality Reduction
- 14. Labels: The Ground Truth of Data
- 15. Weights: Determining Feature Importance
- 16. Bias: Adjusting the Output Baseline
- 17. Multiple Choice Quiz
- 18. Loss Functions: Comparing Predictions to Reality
- 19. Cost Functions: Average Error Across All Data
- 20. The Goal of Training: Optimization and Gradient Descent
- 21. Fill-in-the-Blank Quiz
What is the process of converting categorical data into numbers called?
Standardization
Normalization
Encoding
Clustering
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help