MACHINE LEARNING • LESSON 6

Outliers

An outlier is a value that is unusually far away from most other values in a dataset. Outliers can sometimes represent mistakes, but they can also represent real and important situations.

THE SIMPLEST DEFINITION

An outlier is a value that is very different from most other values.

For example, if most customers are between 20 and 60 years old and one value is 250, that value is far away from the others and should be investigated.

01

A Simple Example

Suppose we have the following customer ages:

24
27
29
31
34
95

Most values are between 24 and 34, while 95 is much farther away from the rest.

Therefore, 95 may be considered an outlier in this dataset.

Outlier simply means "very different from the other values." It does not automatically mean "wrong."
02

Outlier vs Incorrect Data

This is one of the most important differences to understand.

INCORRECT DATA Age = 250

Probably a data-entry or data-quality problem.

OUTLIER Age = 95

Unusual, but it could be a real value.

An incorrect value is wrong. An outlier is simply unusual.

Sometimes an outlier is incorrect, but sometimes it is completely valid.

03

A Real Example: House Prices

Imagine a dataset containing house prices:

₹40 lakh
₹45 lakh
₹50 lakh
₹55 lakh
₹5 crore

Most houses are between ₹40 lakh and ₹55 lakh. A ₹5 crore house is very different from the others.

That makes ₹5 crore an outlier in this particular dataset.

But that does not mean the ₹5 crore value is wrong. It could be a genuine luxury property.

The correct question is: "Why is this value different?"
04

Why Can Outliers Matter?

Some machine learning models can be strongly affected by extreme values.

For example, suppose we calculate the average income of these customers:

₹30,000
₹35,000
₹40,000
₹45,000
₹10,00,000

Most customers earn between ₹30,000 and ₹45,000, but one customer earns ₹10,00,000.

That extreme value can pull the average upward and make the dataset look different from what most customers actually look like.

MOST VALUES ₹30K–₹45K
+
EXTREME VALUE ₹10 Lakh
POSSIBLE EFFECT Average is pulled upward
05

Where Do Outliers Come From?

An outlier can have different causes.

Data Entry Error Someone entered 500 instead of 50.
Genuine Extreme Case A real customer may genuinely have an unusually high income.
Measurement Problem A sensor or measurement system may produce an abnormal value.

This is why we should investigate an outlier before deciding what to do with it.

06

Should We Remove Outliers?

Not automatically.

IF IT IS WRONG Correct or remove it

Example: Age = 250 because of a typing mistake.

IF IT IS REAL Consider keeping it

Example: A genuine customer with very high income.

Removing a real observation simply because it is unusual can make the dataset less representative of reality.

07

Simple Real-World Example

Imagine an e-commerce company wants to analyze customer spending.

Customer Monthly Spending Typical? Action
Rahul ₹5,000 Yes Keep
Priya ₹7,000 Yes Keep
Arun ₹5,00,000 Outlier Investigate

Arun's spending is dramatically higher than the others.

We should investigate why. Perhaps Arun is a business customer who genuinely spends ₹5,00,000 every month.

If that is true, removing Arun just because he is unusual would be a mistake.

IMPORTANT

Outliers Depend on the Dataset

A value can be an outlier in one dataset but completely normal in another.

DATASET A Customer Income

₹10 lakh may be an extreme value.

DATASET B CEO Income

₹10 lakh may not be unusual.

An outlier is always evaluated in context. There is no universal number that automatically means "outlier."

REMEMBER THIS

Outlier Does Not Mean Wrong.

An outlier is simply a value that is unusually different from most other values. Investigate it first. Remove or correct it only when there is a good reason.

QUICK CHECK

What Should You Do?

Most customers spend ₹2,000–₹10,000 per month. One customer spends ₹2,00,000.

Immediately delete the customer ❌ Don't do this
Investigate the value ✅ Correct first step
Automatically call it incorrect ❌ Not necessarily
Answer

First investigate the value. It may be a genuine high-spending customer or it may be a data-entry mistake. Only after understanding the reason should you decide whether to keep, correct, or remove it.

NEXT TOPIC

Encoding Categorical Data

Machine learning models often need numerical inputs, but real datasets contain values such as city, gender, membership type, and product category. Next, we will learn how to convert categorical information into a form a model can use.