MACHINE LEARNING • LESSON 5

Categorical Features

Categorical features describe groups or categories rather than quantities. They tell the model what kind of thing something is.

THE SIMPLEST DEFINITION

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.

01

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:

CATEGORY Electronics
CATEGORY Clothing
CATEGORY Furniture

These values don't represent an amount. They tell us which group each product belongs to.

02

Simple Customer Example

Suppose we have information about customers.

FEATURE Age

29

CATEGORICAL FEATURE City

Hyderabad

CATEGORICAL FEATURE Membership

Premium

Age is a numerical feature because 29 represents a measurable quantity.

City and membership are categorical features because they represent categories.

03

Numerical vs Categorical

The easiest way to understand categorical features is to compare them with numerical features.

NUMERICAL FEATURE Age = 29

Represents a measurable quantity.

CATEGORICAL FEATURE City = Hyderabad

Represents a category or group.

A useful question to ask is:

"Does this value represent an amount, or does it represent a category?"
04

Common Examples

Categorical features appear in many real-world datasets.

COLOR Red
COUNTRY India
PAYMENT Credit Card
PRODUCT TYPE Laptop
MEMBERSHIP Premium
DEVICE Mobile
05

A Categorical Feature Can Have Many Values

One categorical feature can contain many different categories.

For example, the feature City could contain:

Hyderabad
Mumbai
Delhi
Chennai
Bengaluru

Each city is a different category of the same feature.

06

Categorical Features in a Dataset

Consider this simple customer dataset:

Age City Membership Purchased
29 Hyderabad Premium Yes
35 Mumbai Basic No
24 Delhi Premium Yes

Here:

Age Numerical feature
City Categorical feature
Membership Categorical feature
Purchased Label in this problem
07

An Important Point: Categories Are Not Amounts

Suppose we have:

CITY Hyderabad
CITY Mumbai

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.

REMEMBER THIS

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?"

QUICK CHECK

Which Features Are Categorical?

Imagine a customer dataset containing these values:

Age = 29 Numerical
City = Mumbai Categorical
Payment = Credit Card Categorical
Answer

City and Payment are categorical features because their values represent categories. Age is numerical because it represents a measurable quantity.

NEXT TOPIC

Feature Selection

Not every feature is useful for every machine learning problem. Next, we will learn how to choose the features that are actually useful for the model.