AI Glossary / Deep learning / Beginner
Preprocessing
Definition
Preprocessing is the preparation and transformation of data before it is used by a model or another analysis step. It can include checking formats, handling missing values, scaling measurements, encoding categories and constructing a consistent input representation.
What it means
Raw records rarely arrive in exactly the form a model needs. Dates may use different formats, categories may be written inconsistently, and measurements may use incompatible units. Preprocessing establishes how those records become usable inputs.
Some operations follow a fixed rule, such as converting centimeters to meters. Others learn information from a dataset, such as a mean used for imputation or a vocabulary used for encoding text. That distinction matters when evaluating a model.
Preprocessing is broader than deep learning and is not automatically beneficial. Removing unusual values can erase important cases; simplifying text can remove meaning. Each transformation should have a purpose tied to the data and task, with enough documentation to reproduce the same interpretation later.
How it works
Start by defining an input schema: expected fields, types, units and permitted missing values. Check whether the data meets that contract and decide how exceptions should be handled.
Then apply appropriate transformations. Numerical features may be scaled; categorical values may be encoded; missing values may receive a documented treatment. Different model families have different requirements, so one universal recipe is inappropriate.
For an ordinary held-out evaluation, fit learned transformations using the training subset only, then apply the fitted transformation to validation or test inputs. During cross-validation, fitting belongs inside each training fold. Otherwise information from evaluation data can influence the model indirectly.
Save the fitted preprocessing state with the model and use the same interpretation at prediction time. Handle unseen categories, unexpected units and missing fields explicitly. A pipeline can help keep the steps together, but it does not decide whether their underlying assumptions are sensible.
Three practical examples
- A demand model converts all recorded quantities to a common unit and applies a scaler fitted on its training data.
- A service-ticket classifier uses a consistent text representation when learning from historical messages and processing new ones.
- A sensor-analysis workflow identifies missing readings, retains a missingness indicator where useful and applies a documented imputation method.
Think of it this way
Think of preparing ingredients to a recipe's specified measurements before cooking. Converting units and deciding what to do with a missing ingredient can determine whether the recipe works as intended.
The analogy does not imply that data should always be made uniform or that unusual records are spoiled. In some tasks, differences and rare cases carry the most important information. Preparation must preserve what the task needs rather than merely making the inputs look tidy.
Worked example
Fit once, then apply consistently
Suppose a training feature contains the invented values 10 and 20. A min-max transformation fitted on this training set uses minimum 10 and maximum 20, so it maps a value x to (x − 10) / 10. The training values become 0 and 1.
A later value of 30 becomes 2 under that same transformation. Being outside the original zero-to-one range is possible when a new value exceeds the training range; clipping would be a separate design choice.
If the training and later value were combined before fitting, the maximum would become 30 and the original training value 20 would instead map to 0.5. Evaluation information would have changed the representation used to learn. If the later data were independently refitted, its scale would no longer match what the model expects. The correct treatment depends on the stated evaluation and deployment protocol.
Illustrative case study
Fictional example: Birch Maintenance builds a model using temperature readings from several sites. Historical records store all temperatures in Celsius. A new site's feed provides Fahrenheit values in a field with the same name.
The prediction service successfully parses the numbers and reports no software error, but its outputs shift sharply. Retraining a larger model would not resolve the ambiguous input contract. The team adds explicit unit metadata and checks the conversion before applying the saved training transformations.
It also revisits missing readings that were previously replaced with zero. Zero degrees can be a genuine observation, so the revised representation distinguishes absent measurements from measured values.
The case illustrates that reliable preprocessing depends on meaning, not just numerical compatibility. A model can accept an input array while receiving a fundamentally different description of the world.
Common misconceptions and mistakes
- Preprocessing means deleting all outliers. Unusual observations may be valid and important.
- Unsupervised transformations cannot leak information. Scaling, imputation and dimensionality reduction can still learn from evaluation data.
- Test data should be left unprocessed. It should receive the appropriate transformation fitted without using its held-out information.
- A successful conversion proves data quality. Correct types do not establish correct units, labels or measurement meaning.
Business use
Preprocessing often determines whether a model behaves consistently between development and daily use. Treat it as part of the product's data contract, with ownership for changes in source systems and interpretation.
Review how many records each step changes or excludes, and examine whether exclusions disproportionately remove a relevant class of cases. Preserve the versioned transformation settings needed to reproduce predictions. When model performance changes, inspect the input pipeline alongside the model itself. A changed category spelling, unit or missing-value convention can matter more than a change in the prediction algorithm.
People also ask
Is preprocessing the same as feature engineering?
They overlap. Preprocessing prepares representations; feature engineering often emphasizes creating informative variables from available data.
Must every numerical column be standardized?
No. The need depends on the model and interpretation of the feature.
Can preprocessing happen before splitting data?
Fixed, independently specified operations may be harmless, but transformations learned from data must respect the evaluation split. Grouping, duplication and temporal leakage also require an appropriate split design.
Check your understanding
A team fits a missing-value imputer on the entire dataset, then splits the result into training and test sets. Has it kept the test set completely independent of model preparation?
Answer: No. The imputation values were influenced by the test records. Fit the learned transformation within the training portion of the evaluation protocol.
Related terms
- Data cleaning
- Feature engineering
- Data leakage
- Pipeline
- Training-serving skew
- feature scaling
- imputation
- categorical encoding
Learn next
Read data leakage and feature scaling. List each step in a proposed preprocessing pipeline, marking whether it follows a fixed rule or learns from data, and record where that learned state is fitted and reused.
More in Deep learning
- Physics-informed neural networks - Physics-informed neural networks, or PINNs, are neural models trained using physical equations or related scientific constraints as well as available...
- Planning and control layer - The planning and control layer is the part of a robot architecture that converts goals and an estimated world state into planned motion and executable...
- Pooling Layer - A pooling layer summarizes groups of values in a neural-network representation.
- Probabilistic Topic Model - A probabilistic topic model is a statistical model that represents a collection of documents through latent themes and probability distributions.
- Promoter based genetic algorithm - The promoter based genetic algorithm, or PBGA, is a neuroevolution method that uses promoter-like switches to control which encoded neural units are...
- Proportional Hazards Model - A proportional hazards model describes how characteristics multiply the instantaneous rate of an event among cases that have not yet experienced it.
Sources
scikit-learn developers, preprocessing transformations: https://scikit-learn.org/stable/modules/preprocessing.html. Common pitfalls, inconsistent preprocessing and leakage: https://scikit-learn.org/stable/common_pitfalls.html. Google Machine Learning Glossary, data and feature terminology: https://developers.google.com/machine-learning/glossary. The numerical example and maintenance case are original illustrations.
Previous: Prepositions Next: Prescriptive analytics