MACHINE LEARNING • LESSON 3

Collecting Data

Machine learning models learn from data. Before training a model, we need to collect data that is relevant to the problem we are trying to solve.

THE CORE IDEA

A model can only learn from the information we give it.

If the data does not contain useful information about the problem, the model will struggle to learn useful patterns. Good machine learning starts with useful, relevant data.

01

What Is Data in Machine Learning?

Data is the information that we give to a machine learning system so that it can learn patterns.

For example, suppose we want to predict house prices.

We might collect information such as:

  • House size
  • Number of bedrooms
  • Location
  • Age of the house
  • Selling price

Each house becomes an example that the model can learn from.

02

A Simple Dataset

Imagine we collect information about several houses:

Size Bedrooms Age Price
1,000 sq ft 2 10 years $200,000
1,500 sq ft 3 7 years $300,000
2,000 sq ft 4 5 years $400,000

This collection of examples is called a dataset.

The model can study these examples and learn relationships between the house information and its price.

03

Where Can We Get Data?

Machine learning data can come from many different sources.

DATABASES Company or application data

Customer records, orders, products, transactions, and other stored information.

FILES CSV, Excel, JSON

Existing datasets stored in files can be used for machine learning.

APIs Data from other services

An API can provide data from another application or service.

SENSORS Real-world measurements

Devices can collect information such as temperature, movement, or location.

04

Example: E-Commerce Data

Imagine you work on an e-commerce website and want to predict whether a customer will purchase a product.

You could collect information such as:

CUSTOMER Previous purchases
BEHAVIOR Products viewed
ACTIVITY Time spent on website
HISTORY Previous orders

These examples may contain useful information that helps the model learn patterns related to purchasing behavior.

05

Relevant Data Matters

Collecting a large amount of data does not automatically make a machine learning project better.

The data should be relevant to the problem.

For example, if we want to predict house prices, house size and location may be useful information.

Something completely unrelated, such as the color of the owner's phone, is unlikely to help predict the house price.

Remember:

More data is not always better. We need useful data, not simply more data.

06

More Examples Usually Help

A model generally benefits from having enough useful examples to learn from.

Consider two situations.

SMALL DATASET 10 Houses

The model has very few examples from which to learn house-price patterns.

LARGER DATASET 50,000 Houses

The model has many more examples covering different house sizes, locations, and prices.

More useful examples can give a model more information about the problem.

However, simply increasing the dataset size does not guarantee a good model. The data still needs to be relevant and usable.

07

Data Should Represent the Real Problem

Another important question is: Does the data represent the situation where the model will actually be used?

Imagine we build a model to predict product purchases using only data from customers who already purchased something.

That dataset may not represent customers who visit the website but never purchase.

If the training data does not represent the real situation, the model may struggle when it sees new real-world data.

REAL WORLD Many types of customers
COLLECT DATA Capture representative examples
MODEL Learn useful patterns
08

What Makes Data Useful?

At this stage, remember these basic characteristics of useful machine learning data.

RELEVANT Related to the problem
ENOUGH Contains sufficient examples
REPRESENTATIVE Reflects the real situation
USABLE Can be prepared for training

The next step is to examine the collected data and prepare it for machine learning.

09

What Happens After Collecting Data?

Raw data is usually not ready to give directly to a machine learning model.

It may contain missing information, duplicates, incorrect values, or other problems.

That is why collecting data is followed by data preparation.

STEP 1 Collect Data
STEP 2 Prepare Data

We will learn the details of missing values, duplicate data, incorrect data, outliers, encoding, and scaling in the next topic.

KEY IDEA

Good Machine Learning Starts With Good Data.

Collect data that is relevant to the problem, contains enough useful examples, and represents the real situation where the model will be used.

QUICK CHECK

Which Dataset Is More Useful?

You want to build a model that predicts house prices.

Dataset A contains house size, location, bedrooms, age, and actual selling price.

Dataset B contains the house owner's favorite movie, favorite color, and favorite sport.

Answer

Dataset A is much more useful because its information is directly related to house prices.

Dataset B contains information that is mostly unrelated to the prediction problem.

NEXT TOPIC

Preparing Data

We have collected the data. Now we need to make sure that the data is clean, consistent, and suitable for machine learning.