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.
📚 This post is part of the "Machine Learning" series
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.
Still in this guide
Data Exploration with Pandas: info(), describe(), groupby()
Data Preprocessing: Normalisation vs. Standardisation
Transforming Features with MinMaxScaler and OneHotEncoder
Creating and Evaluating a Keras Neural Network on Preprocessed Data
Conclusion: A One-Step Column Transformer Before Model Training
References
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):
Full content temporarily unavailable — refresh in a moment
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.
New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.
References
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/
Want the Python virtual environments cheat sheet and the Python errors and logging cheat sheet in your inbox?
Python Virtual EnvironmentsPython Errors & LoggingFantastic AI: The 2026 Toolkit
+4more free gifts
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.