MACHINE LEARNING • LESSON 6

Duplicate Data

Duplicate data means the same record appears more than once in a dataset when those records represent the same real-world example.

THE SIMPLEST DEFINITION

One real-world record should not accidentally appear multiple times.

Duplicate records can make some examples appear more important than they really are. Before training a model, we should check whether duplicate records exist and decide how to handle them.

01

What Does Duplicate Data Look Like?

Imagine we have customer information:

Name Age City Orders
Rahul 29 Hyderabad 5
Rahul 29 Hyderabad 5
Priya 32 Mumbai 3

The first and second rows contain exactly the same information.

If both rows represent the same customer record, the second row is a duplicate.

02

Why Can Duplicate Data Be a Problem?

Machine learning models learn from the examples in the training dataset.

If the same example appears many times accidentally, that example can have more influence than it should.

CORRECT DATA Customer A

Appears once.

DUPLICATED DATA Customer A

Appears multiple times.

The model may effectively see Customer A as several training examples even though there is only one real customer record.

03

A Simple Example

Suppose we are building a model to predict whether a customer will purchase a product.

CUSTOMER Rahul

Orders: 5

Visits: 12

DUPLICATE Rahul

Orders: 5

Visits: 12

If these two rows represent the same customer and were accidentally imported twice, the dataset now contains incorrect duplicate information.

The problem is not that Rahul is a customer. The problem is that the same record was counted twice.

04

How Do Duplicates Happen?

Duplicate records can appear for several practical reasons.

Data Imported Twice The same file or records may accidentally be imported more than once.
System Synchronization Data from different systems may contain the same record.
Repeated Data Collection The same information may be recorded multiple times by mistake.
05

Duplicate Does Not Always Mean "Same Name"

This is an important point.

Two records with the same name are not automatically duplicates.

RECORD 1 Rahul

Hyderabad

Age: 29

RECORD 2 Rahul

Chennai

Age: 41

These records have the same name, but they may represent two different people.

Duplicate detection should consider what identifies the same real-world record, not just one field.
06

What Should We Do With Duplicates?

If we confirm that two records represent the same real-world example and one is an accidental duplicate, we can remove the unnecessary duplicate.

BEFORE Rahul

Record 1

DUPLICATE Rahul

Record 2

AFTER One Record

Keep the appropriate record.

But don't blindly delete records just because some values look similar. First determine whether they really represent the same observation.

07

Real-World Example

Imagine an e-commerce company combines customer data from two systems.

Customer ID Name Orders Source
1001 Rahul 5 Website
1001 Rahul 5 CRM
1002 Priya 3 Website

Customer ID 1001 appears twice with the same customer information.

This could be a duplicate created when the two systems were combined.

Before training the model, the data team should investigate the duplicate and decide which record should remain.

REMEMBER THIS

One Real-World Example Should Not Be Accidentally Counted Multiple Times.

Duplicate data can give some examples too much influence during training. Identify genuine duplicates and handle them before building the model.

QUICK CHECK

Are These Records Duplicates?

Rahul, 29, Hyderabad Record A
Rahul, 29, Hyderabad Same information → likely duplicate
Rahul, 41, Chennai Different information → not automatically duplicate
Answer

The first two records are likely duplicates if they represent the same person and the same observation. The third record is not automatically a duplicate just because the name is also Rahul.

NEXT TOPIC

Incorrect Data

Duplicate records are one type of data problem. Next, we will learn how incorrect values can enter a dataset and how they can affect a machine learning model.