Skip to main content
XenonStack

Enterprise AI

XenonStack Blog Data Preparation for AI: Roadmap, Steps and Tools

| Published | Updated

Data Preparation for AI: Roadmap, Steps and Tools
8:31

Key takeaway

  • Data preparation turns raw data into model-ready inputs. Learn the steps for missing values, scaling, encoding and class balance, and where agents fit.

Data preparation is the work of turning raw, inconsistent data into clean, complete and well-formed inputs that a machine learning model can learn from. It covers profiling the data, fixing quality problems, transforming features and checking that the result is fair to the people and cases the model will serve.

This roadmap is for data scientists, ML engineers and analytics leads who want a repeatable order of work before modelling. It covers the steps, the choices inside each step, a comparison of common techniques, how AI agents change the work, and what to do first.

Why does data preparation matter for AI?

A model predicts from the historical data it is given, so gaps, duplicates and skew in that data become gaps, duplicates and skew in its output. Most business data is not ready for modelling: it is spread across systems, mixes text and numbers, and carries human errors. Preparation is where these problems are found and decided on in the open, with a record of each decision, rather than discovered after a model misbehaves.

Two-column diagram. Clean and transform: profile, missing values, outliers and duplicates, scale and encode. Engineer and check: select features, construct features, balance classes, log decisions.

What are the steps in a data preparation roadmap?

  1. Profile the data with exploratory data analysis: row and column counts, types, missing values, ranges, relationships between features and the target.
  2. Clean it: handle missing values, outliers and duplicate rows.
  3. Transform it: scale numeric features and encode categorical ones.
  4. Engineer features: select, construct or aggregate features that carry signal.
  5. Balance and split: deal with class imbalance and hold out data for testing.
  6. Document each step so the same pipeline can be rerun and audited.

How do you handle missing values, outliers and duplicates?

The scikit-learn imputation guide notes that many real world datasets contain missing values, often encoded as blanks, NaNs or other marker values, and that most estimators assume every value is numerical. Its basic option is to discard rows or columns with missing values, which comes at the price of losing data that may be valuable. A better strategy, it says, is to impute: infer missing values from the known part of the data, for example with a constant or the mean, median or most frequent value of each column. It also points out that keeping a record of which values were missing can be informative, which is what its MissingIndicator does.

Outliers need a decision rather than a reflex. Some are errors and should be corrected or removed, and some are real events the model must see. Duplicate rows can overweight some cases and make a model look more accurate than it is, so remove exact duplicates and investigate near duplicates. Features that hardly vary add little, and the same is true of a feature that repeats another almost exactly, so review both before training.

How do you scale and encode features?

The scikit-learn preprocessing guide says standardisation of datasets is a common requirement for many estimators, which may behave badly if features do not look roughly like standard normally distributed data. Its scalers compute their statistics on the training set so that the same transformation can be applied to the test set later, and that order matters: fit on training data only, to avoid leaking information from the test data. The guide also says that if data contains many outliers, scaling with the mean and variance is likely not to work well, and a robust scaler can be used instead.

Categorical features must be converted to numbers. The guide describes ordinal encoding, which turns categories into integer codes, and warns that many estimators would read those codes as ordered, which is often not wanted. One-hot encoding creates one binary feature per category and avoids that problem.

TaskCommon optionsWatch out for
Missing valuesDrop rows or columns, impute with a constant or a column statistic, add a missing indicatorDropping can discard useful data
ScalingStandardisation, min-max scaling, robust scalingFit on training data only
Categorical encodingOrdinal codes, one-hot encoding, target encoding for many categoriesInteger codes imply an order
Class imbalanceRandom over-sampling, SMOTE, under-sampling, class weightsResample training data only
Too many featuresFeature selection, PCA, aggregationKeep features that can be explained

How do you engineer features and balance classes?

Feature selection removes columns that add load without helping the output. Feature construction builds new columns from existing ones, and principal component analysis combines original features linearly into fewer new ones when the data is very wide. Feature aggregation summarises detail, for example daily store sales into monthly totals, which reduces the number of records and the processing time. The scikit-learn guide adds that centring and scaling do not remove linear correlation between features, and that PCA with whitening can be used for that.

When one class is much rarer than another, a classifier can score well by ignoring it. The imbalanced-learn documentation describes random over-sampling as sampling with replacement from the available minority samples, and SMOTE as interpolating between existing samples instead of copying them. Apply resampling to training data only, and keep a test set that reflects real class frequencies.

How do you make data preparation explainable and fair?

Fairness is easier to protect when each choice is recorded. Keep a short log of what was dropped, imputed, scaled or encoded, and why. Compare feature distributions before and after cleaning, check that groups affected by the model are not removed by missing value rules, and watch for drift between training data and new data. Feature importance helps reviewers see which inputs drive predictions. Related reading: roadmap for algorithm and model explanation and edge analytics applications.

How do AI agents change data preparation?

Agents can now profile new datasets, propose cleaning steps, write pipeline code and run it. That speeds the work but raises the stakes on context: an agent that cleans data without knowing what a column means, who owns it or which policy governs it can quietly remove the very records a model needs. Data preparation done by agents therefore needs the same record of decisions as human work, with approvals for changes that affect a model in production. For governed data and context, see ElixirData, XenonStack's Context OS.

What should you do first?

  1. Choose one model or report and list the data it depends on.
  2. Profile that data and write down the quality problems found.
  3. Fix missing values, duplicates and outliers with a stated rule for each.
  4. Build scaling and encoding into a pipeline fitted on training data only.
  5. Log every step so the preparation can be rerun and reviewed.

To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What is data preparation in machine learning?

It is the process of cleaning, transforming and organising raw data so that a model can learn from it. It includes profiling, handling missing values and outliers, scaling, encoding and feature engineering.

Should you drop rows with missing values or impute them?

Dropping rows is the basic option but loses data that may be valuable. The scikit-learn guide describes imputing, which infers missing values from the known part of the data, as a better strategy, and suggests keeping track of which values were missing.

Why fit scalers on training data only?

Fitting on training data and then applying the same transformation to test data keeps information about the test set out of training, so the test result is an honest estimate.

How do you handle imbalanced classes?

Common approaches are random over-sampling, SMOTE-style interpolation, under-sampling or class weights, applied to training data only and judged on a test set that keeps real class frequencies.

Where do AI agents fit in data preparation?

Agents can profile data, propose fixes and run pipelines, but they need the meaning, ownership and policy context of each dataset, and every change should be recorded and approved where it affects production models.

Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.

Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.

Table of Contents

dr-jagreet-gill

Dr. Jagreet Kaur

Chief AI Officer, XenonStack

LinkedIn profile

Dr. Jagreet Kaur specializing in Generative AI for synthetic data, Conversational AI, and Intelligent Document Processing. With a focus on responsible AI frameworks, compliance, and data governance, she drives innovation and transparency in AI implementation

Get the latest articles in your inbox

Subscribe Now

Interested in solving your challenges with the XenonStack team?
Get Started

Tell us about you and your priorities so we can prepare the right conversation. It takes about 2 minutes.

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Continue