Data preparation

Data preparation is the work of collecting, checking, cleaning, transforming and organising raw data so it can be analysed or used to train and run a machine learning model.

Raw data rarely arrives ready to use. Dates are written three different ways, sizes are recorded in square feet in one system and square metres in another, some records are duplicated and others have gaps. Data preparation is everything done to fix that before analysis starts. A typical sequence is to gather the relevant data, examine it to see what state it is in, clean and validate it (removing errors, filling or flagging missing values, converting to standard formats, masking sensitive details), transform and enrich it, and store the result where analysts or models can reach it.

For machine learning there are further steps. Numbers are usually rescaled so that features measured on very different scales do not swamp each other, continuous values are sometimes grouped into ranges, categories are converted into numbers, and every example is turned into a feature vector a model can read. Google's Machine Learning Crash Course puts the balance of work plainly: practitioners spend far more time evaluating, cleaning and transforming data than building models.

The step is old. CRISP-DM, the process model for data mining published in 1999, lists data preparation as one of its six phases, between understanding the data and building the model. What has changed is scale, but the questions are the same: what is in the data, what is wrong with it and what should be removed.

It also has legal weight. The EU AI Act's Article 10 requires providers of high-risk AI systems to apply data governance practices that cover data preparation operations such as annotation, labelling, cleaning, updating, enrichment and aggregation.

Two practical points matter most. First, preparation has to be done in the right order: scikit-learn's documentation warns that fitting a scaling step on all the data before splitting off a test set leaks information and inflates test scores. Second, every step has to be recorded so it can be applied in exactly the same way to new data when the model is in use. A model trained on carefully prepared data and fed raw data in production will not behave as tested.

Common questions

What are the steps of data preparation?

A common sequence is to gather the data, explore and assess it, clean and validate it, transform and enrich it, and store the result. For machine learning, transformation usually includes scaling numbers, encoding categories and building the feature vectors the model reads.

Why does data preparation take so long?

Because data from real systems is messy in ways that differ from one source to the next, and each problem needs a decision: whether to fix, remove or flag it. Google's Machine Learning Crash Course notes that practitioners spend far more time evaluating, cleaning and transforming data than building models.

What is the difference between data preparation and data cleaning?

Data cleaning is one part of data preparation: finding and fixing errors, duplicates and missing values. Data preparation is the whole job, which also includes gathering data, transforming it into the right form and storing it for use.

Can data preparation cause errors in a model?

Yes. If preprocessing such as scaling or feature selection is fitted on the whole dataset before the test set is separated, information from the test set leaks into training and test scores become too optimistic. Applying different preparation in production from the one used in training also makes a model behave differently from how it was tested.

Finding more

Search for "data preparation for machine learning", "data cleaning" or "preprocessing pipeline". Practical course material from machine learning providers and the documentation of libraries such as scikit-learn and pandas are the most useful places to start. For regulated uses, read the data governance requirements in the EU AI Act directly.

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.