




Investing time in data preparation reduces rework, improves reproducibility, and often yields greater performance gains than tuning model hyperparameters.
- Improved model accuracy and robustness
- Consistent, reliable inputs for training and inference
- Easier feature engineering and richer representations
- Reduced overfitting and faster training convergence
- Mitigated bias and fairer model behavior
Recognizing these problems early prevents setbacks during training and improves downstream evaluation.
Typical data preparation workflow
- Cleaning — Correct typos, impute missing values, remove duplicates, standardize formats.
- Transformation — Scale or normalize numeric features; convert types (e.g., strings → numeric).
- Feature engineering — Derive informative features from raw columns.
- Labeling — Ensure accurate and consistent target values for supervised learning.
- Validation — Test prepared data with holdouts, cross-validation, and drift checks.

- Imputation
- Numeric: replace missing values with mean/median or use model-based imputation.
- Categorical: replace with mode or a special category such as
"missing".
- Scaling
- Standardize (z-score) or normalize (min-max) features like price or area so they contribute proportionally.
- Encoding
- One-hot encoding for low-cardinality categories; ordinal encoding for ordered categories; target or binary encoding for high-cardinality features.
- Handling class imbalance
- Oversample minority class (SMOTE), undersample majority class, or apply class weights in the loss function.

- House age = current year − year built
- Size per bedroom = total area ÷ number of bedrooms

- Preserve a raw data snapshot so you can re-run preparation if assumptions change.
- Automate and version your preprocessing (e.g., with pipelines) to ensure reproducibility.
- Validate assumptions continuously (missingness patterns, covariate shift, label quality).
- Monitor models in production for data drift and trigger re-preparation when distributions change.
Avoid data leakage: do not compute statistics (e.g., scaling parameters or imputation values) using the full dataset including test/validation sets. Fit transformers on training data only and apply them to validation/test sets.
- Cleaning removes errors and harmonizes formats.
- Transformation converts raw values into model-ready features.
- Feature engineering creates context-rich inputs that improve learning.
- Labeling provides correct targets for supervised models.
- Validation ensures data quality and model generalizability.