Categorical Features
Categorical features describe groups or categories rather than quantities. They tell the model what kind of thing something is.
Categorical features describe categories or groups.
Examples include city, product type, color, payment method, and membership type. These values represent different categories rather than amounts that can be measured directly.
What Does "Categorical" Mean?
A category is simply a group or type that something belongs to.
For example, suppose an online store has different product categories:
These values don't represent an amount. They tell us which group each product belongs to.
Simple Customer Example
Suppose we have information about customers.
29
Hyderabad
Premium
Age is a numerical feature because 29 represents a measurable quantity.
City and membership are categorical features because they represent categories.
Numerical vs Categorical
The easiest way to understand categorical features is to compare them with numerical features.
Represents a measurable quantity.
Represents a category or group.
A useful question to ask is:
Common Examples
Categorical features appear in many real-world datasets.
A Categorical Feature Can Have Many Values
One categorical feature can contain many different categories.
For example, the feature City could contain:
Each city is a different category of the same feature.
Categorical Features in a Dataset
Consider this simple customer dataset:
Here:
An Important Point: Categories Are Not Amounts
Suppose we have:
Mumbai is not "more" city than Hyderabad, and Hyderabad is not "less" city than Mumbai.
They are simply two different categories.
This is important because machine learning models work with numerical representations internally. Later, in Data Preparation, we will learn how categorical values can be converted into a form that machine learning algorithms can use.
Categorical Features Tell Us "What Type?"
Numerical features usually tell us "How much?" or "How many?". Categorical features tell us "What type?", "Which group?", or "Which category?"
Which Features Are Categorical?
Imagine a customer dataset containing these values:
City and Payment are categorical features because their values represent categories. Age is numerical because it represents a measurable quantity.