Data cleaning

Data cleaning is the process of finding and fixing or removing corrupt, inaccurate, duplicated or irrelevant records in a dataset before it is analysed or used to train a model.

Real data is messy. Data cleaning, also called data cleansing, is the work of detecting and correcting, or removing, records that are corrupt, inaccurate or irrelevant. It differs from validation at the point of entry, which rejects bad data as it arrives: cleaning works on data that has already been collected.

The work follows a familiar pattern. Analysts audit the data for contradictions, check that values have the right type and fall in sensible ranges, and parse fields to see whether they fit the expected format. They standardise, so that every date uses one format and every weight one unit. They remove duplicates, decide what to do about missing values, and investigate outliers. Some checks are simple logic: a hospital discharge date cannot come before the admission date.

Machine learning adds its own concerns. Google's Machine Learning Crash Course lists the usual culprits as missing values, duplicate examples, bad feature values such as typos or faulty sensor readings, wrong labels, and whole sections of bad data, such as a day of readings collected while a network kept crashing. For examples with missing values it suggests either deleting them or filling in a reasoned estimate such as the average, and adding a column that flags which values were filled in so the model can learn to trust them less.

For large language models, cleaning happens at web scale. OpenAI's 2020 GPT-3 paper reports that unfiltered or lightly filtered Common Crawl data was of lower quality than curated datasets. The team filtered the crawl by its similarity to high-quality reference text and removed near-duplicate documents, partly so that its held-out validation set stayed a fair measure of overfitting. The crawl shrank from 45TB of compressed text to 570GB.

Cleaning has limits. It cannot recover information that was never captured, and filling a blank with unknown does not make a record complete. Every rule about what to drop or correct is also a judgement that shapes the result, so the cleaning steps belong in a dataset's documentation alongside the data itself.

Common questions

Is data cleaning the same as data cleansing?

Yes. Data cleaning, data cleansing and data scrubbing are used for the same process of finding and fixing or removing errors in existing data.

What are the main steps in data cleaning?

Typical steps are auditing the data for problems, validating types and ranges, standardising formats and units, removing duplicates, handling missing values, investigating outliers and then re-checking the result. The exact steps depend on the data and what it will be used for.

How should missing values be handled?

The two main options are to delete incomplete records, if enough complete ones remain, or to fill the gaps with reasoned estimates such as the mean or median. Google's guidance suggests flagging filled-in values and, when unsure, comparing models built both ways.

Why does data cleaning matter for AI?

A model learns whatever is in its data, including errors, duplicates and junk. Wrong labels teach wrong answers, duplicates distort what the model treats as common, and overlap between training and test data makes a model look better than it is.

Finding more

Search for "data cleaning steps", "handling missing values imputation" or "deduplication training data" to see the techniques. Reliable sources include Google's Machine Learning Crash Course, documentation for data tools such as pandas, and the dataset sections of model papers on arXiv. When a company says its data is clean, look for a description of what checks were run and what was removed.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.