Book a free call

Collecting Data for Machine Learning: Sources and Quality

Good machine learning starts with good data. Here is where training data comes from, how to collect it, and the checks that keep a dataset usable.

Hertiv engineering teamReviewed by a senior engineer
5 min read
Collecting Data for Machine Learning: Sources and Quality
On this page

Short answer

Collecting data for machine learning means gathering the examples a model learns from, then checking that they are correct, representative and legal to use. The work covers choosing sources, recording how each example was collected, removing duplicates and errors, and splitting the data into training and test sets before any model is built.

What does collecting data for machine learning mean?

Collecting data for machine learning means gathering the examples a model will learn from, in the form the model can use. For a text model that means documents and labels; for an image model it means pictures and boxes; for a tabular model it means rows with known outcomes. If the terms are new, start with what machine learning is before planning the collection.

Collection is not the same as downloading a file. It includes deciding what counts as an example, where it comes from, how it was recorded and whether you are allowed to use it. A dataset without that record is hard to trust, because no one can say what it covers or what it leaves out.

The quality of the collection sets the ceiling for the model. A model trained on incomplete or biased examples will repeat those gaps, and no amount of tuning later fixes data that was never collected.

Where does machine learning data come from?

Machine learning data comes from systems a business already runs, from public sources and from people creating new examples. Most teams start with their own systems, because that data matches the problem best.

Source Examples Watch out for
Internal systems Orders, tickets, logs, CRM records Missing fields, old formats
Public datasets Images, text, sensor data Licences, outdated labels
Web collection Product pages, listings, reviews Terms of use, duplicates
Sensors and devices Readings, images, audio Gaps, calibration drift
Human labelling Judgements, ratings, tags Inconsistent labels, cost
Synthetic data Generated rows and images Gaps the real data would show

Internal data is usually the best starting point, because it reflects the real cases the model will see. Public datasets help for common tasks, but they rarely match a specific business problem on their own. Teams that need labelled examples often pair collection with data annotation, which assigns the correct answer to each example.

How do you collect data for a machine learning dataset?

You collect data for a machine learning dataset by defining the example, choosing the source, recording the method and checking the result before it joins the dataset. Each step is recorded so the dataset can be explained later.

  1. Define what one example is and what its label means.
  2. Choose the source and record how it was obtained.
  3. Pull the data with a script or an export, not by hand.
  4. Remove duplicates, test rows and personal data that is not needed.
  5. Check a sample by hand against the definition.
  6. Store the result with a note on source, date and version.

The hand check in step five is the step teams skip most often, and it is the one that catches the most problems. A sample of 100 examples, checked by a person who knows the task, will show whether the definition is clear and whether the source is sound. Once collected, the data usually moves through a data pipeline that cleans and stores it before training.

What makes a dataset good enough to train on?

A dataset is good enough to train on when it covers the cases the model will see, the labels are right and the test set was kept apart from training. Coverage matters more than size: 10,000 examples of one case teach less than 2,000 spread across the real range.

Four checks are worth running before training:

  • Coverage. Does the data include the rare cases, not just the common ones?
  • Label quality. Do two people labelling the same example agree most of the time?
  • Freshness. Does the data reflect how things look now, or how they looked years ago?
  • Separation. Was the test set split off before any cleaning or tuning, so the score is honest?

If any check fails, fix the data before training. A model trained on a dataset with a leaked test set will report a high score and fail in use, which is worse than a low score you can act on.

Licences, consent and privacy decide whether collected data can be used at all, and they are checked before collection starts, not after. Data from the web may carry a licence or terms that forbid machine learning use, and personal data needs a legal basis and a retention plan.

Three rules keep a team out of trouble: only collect data you have a right to use, remove personal details that the model does not need, and record the source and licence for every batch. When the source is unclear, leave the data out rather than guessing.

Privacy checks also protect the model itself. Personal data in training data can leak through model outputs, so the safest dataset is the one that never held the sensitive fields in the first place. A review of the fields before collection is the cheapest privacy control there is: a field that is never collected can never leak.

Example (hypothetical): building a churn dataset

Example (hypothetical): a subscription business wants to predict which customers will cancel. It defines one example as a customer month, with the label being whether the customer cancelled in the next 30 days.

The team pulls 24 months of billing and usage records, about 48,000 customer months, and removes test accounts and staff accounts, leaving 45,000 examples. It checks 200 examples by hand and finds 6 with wrong labels, a 3% error rate it fixes by tightening the definition of a cancellation.

The arithmetic shows why the hand check matters: 3% of 45,000 is 1,350 wrong labels, enough to teach the model the wrong pattern. After the fix, the team splits off 9,000 examples, or 20%, as a test set before any training begins.

What are the common mistakes?

The most common mistakes in data collection are collecting without a definition, mixing test data into training and ignoring the licence of the source. Each one is cheaper to fix at collection time than after a model has been trained on the data.

  • No definition of an example. Without one, two collectors gather different things and the labels disagree.
  • Test data that leaks into training. If the test set was seen during training, the score means nothing.
  • Collecting more of the easy cases. Volume hides gaps; the rare cases are the ones the model needs.
  • Ignoring licences and terms. Data collected against the terms cannot be used, however good it is.
  • No record of the source. A dataset without a source note cannot be audited or refreshed.

Key takeaways

  • Collection starts with a definition of one example and what its label means
  • Internal systems are usually the best source, because the data matches the real problem
  • Check a sample by hand before training; 100 checked examples catch most problems
  • Keep the test set apart from the start, or the score will flatter the model
  • Record source, date and licence for every batch, and leave out data you cannot use

Frequently asked questions

What is data collection for machine learning?

It is the work of gathering the examples a model learns from, then checking that they are correct, representative and legal to use. It covers choosing sources, recording how each example was collected, removing errors and splitting the data into training and test sets.

How much data do you need for machine learning?

It depends on the task and how varied the cases are. A narrow classification task can work with a few thousand well-labelled examples, while a broad one needs far more. Coverage of the real range matters more than raw volume, so start small and add the cases the model gets wrong.

Can you use data from the web for training?

Only when the licence or terms allow it. Public pages often carry terms that forbid machine learning use, and personal data needs a legal basis. Record the source and licence for every batch, and leave out data whose terms you cannot confirm.

What is the difference between data collection and data labelling?

Collection is gathering the examples; labelling is assigning the correct answer to each one. A team can collect 50,000 records and still have no training data until each record has a label, which is why labelling is often the slower and costlier step.

How do you know if a dataset is good enough?

Check four things: coverage of the real cases including rare ones, label quality measured by whether two labellers agree, freshness against current conditions, and a test set that was split off before training. If any check fails, fix the data before training.

What is synthetic data, and when should you use it?

Synthetic data is generated by a program or a model instead of collected from the real world. It helps when real examples are rare or sensitive, but it can miss the gaps real data would show, so use it to add to real data rather than replace it.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a model and unsure where the training data comes from? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Data Engineering service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call