Preprocessing

Preprocessing is the work of cleaning, transforming and formatting raw data before it is used to train or run a machine learning model.

Raw data is rarely ready for a model. Values are missing, records are duplicated, categories are written as text, numbers sit on wildly different scales. Preprocessing is the set of steps that turns that raw material into something a learning algorithm can use. The usual list includes cleaning out impossible or missing values, removing duplicates, encoding categories as numbers, scaling numeric features, grouping continuous values into bins and selecting or extracting the most useful features.

For a spreadsheet-style model the steps are concrete. A column of countries becomes a set of yes-or-no columns through one-hot encoding. Income, which ranges over orders of magnitude, is log-scaled. Missing ages are filled in or the rows dropped. Libraries such as scikit-learn package these steps as transformers that learn their settings, such as a feature's mean, from the training data only and then apply the same settings to new data. Getting that order wrong leaks test information into training and inflates results.

For large language models, preprocessing happens at web scale. The FineWeb project, described in a June 2024 paper, built a 15-trillion-token training set from 96 Common Crawl snapshots, and its authors tested how choices about deduplication and filtering changed the quality of the resulting models. A 1.3-trillion-token subset filtered for educational content, FineWeb-Edu, produced models that scored markedly better on knowledge and reasoning benchmarks such as MMLU and ARC.

The lesson from both scales is that preprocessing is not housekeeping. Choices about what to remove, how to fill gaps and how to scale values shape what a model learns, and they can introduce or remove bias. They also have to be repeated identically when the model is used, or its predictions will drift from its tests.

Common questions

What are the main steps in data preprocessing?

Typical steps are cleaning (fixing or removing errors and missing values), deduplication, encoding categories as numbers, scaling or normalising numeric features, and selecting or extracting features. The exact mix depends on the data and the model.

What is the difference between preprocessing and data cleaning?

Data cleaning is one part of preprocessing, focused on fixing errors, gaps and duplicates. Preprocessing also covers transformations that are not about errors, such as scaling, encoding and feature extraction.

Why must preprocessing be fitted on training data only?

Steps such as scaling use statistics like the mean or range. If those are calculated with the test data included, the model indirectly sees the test set during training and its scores look better than they really are. This is a form of data leakage.

How is text preprocessed for large language models?

Web text is deduplicated and filtered, for example for quality, before being split into tokens. Projects such as FineWeb have shown that these filtering choices measurably change how well the trained model performs.

Finding more

Search for "data preprocessing machine learning", "scikit-learn pipeline preprocessing" or "LLM pretraining data filtering deduplication". Reliable sources include library documentation such as scikit-learn's, machine learning courses from major providers, and dataset papers on arXiv that report ablation results. Treat claims about a single best preprocessing recipe with care, since the right steps depend on the data and the task.

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.