Elena' s AI Blog

Feature preprocessing

29 Jan 2022 (updated: 14 Sep 2026) / 16 minutes to read

Elena Daehnhardt

Flux: Raw mixed data icons flowing into and transforming into clean uniform numeric grids, representing one-hot encoding an...


TL;DR:
  • Preprocess ML data: one-hot encode categoricals, scale numericals. Use Pandas for encoding, Keras preprocessing for scaling. Mixed data types need different handling—do this before training.

Previous: Part 4 — TensorFlow on M1

Next: Part 6 — Tensors in TensorFlow

Feature Preprocessing for Machine Learning: One-Hot Encoding and Scaling

Feature preprocessing is the set of transformations that convert raw inputs into a form a Machine Learning algorithm can consume, applied before model training. When a dataset mixes feature types, we must prepare the data before feeding it into a Machine Learning algorithm. This happens when inputs (also called features or covariates) include categories such as gender or geographic region alongside features on different numerical scales, for instance a person’s weight or height.

A Machine Learning algorithm typically requires data in a specific type — often numerical only. ML algorithms also perform better or converge faster when data is preprocessed before training. Because the step happens before model training, we call it preprocessing. This article focuses on two main feature-preprocessing methods: feature scaling (normalisation) and feature standardisation.

Data exploration with Pandas, scaling, one-hot encoding and the Keras model follow below.

Data Exploration with Pandas: info(), describe(), groupby()

🔒 Subscribe to keep reading.

Data Preprocessing: Normalisation vs. Standardisation

🔒 Subscribe to keep reading.

Transforming Features with MinMaxScaler and OneHotEncoder

🔒 Subscribe to keep reading.

Creating and Evaluating a Keras Neural Network on Preprocessed Data

🔒 Subscribe to keep reading.

Conclusion: A One-Step Column Transformer Before Model Training

🔒 Subscribe to keep reading.

References

🔒 Subscribe to keep reading.

You've hit a Deep Dive tutorial.

I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2022) 'Feature preprocessing', daehnhardt.com, 29 January 2022. Available at: https://daehnhardt.com/blog/2022/01/29/tensorflow-python-pandas-keras-one-hot-encoding-feature-preprocessing-kaggle-dataset/
All Posts