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.
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.
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.
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.
Where Can We Get Data?
Machine learning data can come from many different sources.
Customer records, orders, products, transactions, and other stored information.
Existing datasets stored in files can be used for machine learning.
An API can provide data from another application or service.
Devices can collect information such as temperature, movement, or location.
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:
These examples may contain useful information that helps the model learn patterns related to purchasing behavior.
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.
More data is not always better. We need useful data, not simply more data.
More Examples Usually Help
A model generally benefits from having enough useful examples to learn from.
Consider two situations.
The model has very few examples from which to learn house-price patterns.
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.
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.
What Makes Data Useful?
At this stage, remember these basic characteristics of useful machine learning data.
The next step is to examine the collected data and prepare it for machine learning.
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.
We will learn the details of missing values, duplicate data, incorrect data, outliers, encoding, and scaling in the next topic.
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.
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.
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.