Today we take a look at how we can apply feature scaling to data sets within scikit-learn in python. This is useful when applying Normalization or standardization to data which allows for machine learning models to perform better.
Dataset is available on my Github
📧 Email: ryannolandata@gmail.com
🍿 WATCH NEXT
In this video, I walk you through feature scaling in Python using scikit-learn to improve your machine learning models. Feature scaling transforms numerical values to the same scale, making your data more consistent and your models more accurate. I cover two essential methods: normalization and standardization.
Normalization scales data between 0 and 1 using the MinMaxScaler, which works by taking your value minus the minimum and dividing by the range. Standardization, on the other hand, creates a mean of zero and standard deviation of one using the StandardScaler, similar to a normal distribution. Unlike normalization, standardization can handle negative values and numbers larger than one, making it better suited for datasets with outliers.
I demonstrate both techniques using real baseball statistics data with 465 players and 13 different features. You'll see exactly how to import the scalers from sklearn.preprocessing, fit and transform your data, and convert the results back into clean pandas dataframes. I also compare the results side by side so you can see how each method changes your data differently, including examining the mean, standard deviation, minimum, and maximum values before and after scaling.
TIMESTAMPS
00:00 Introduction to Feature Scaling
01:35 Setting Up Data with Pandas
03:00 Data Overview and Preparation
04:40 Creating X1 and X2 Variables
05:17 Standard Scaler Implementation
06:45 Reviewing Standardized Data
08:15 Min Max Scaler Implementation
09:27 Comparing Standardization vs Normalization
10:45 Final Results and Wrap Up
OTHER SOCIALS:
Who is Ryan
Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.
Who is Matt
Matt is the founder of Width.ai, an AI and Machine Learning agency. Before starting his own company, he was a Machine Learning Engineer at Capital One.
*This is an affiliate program. We receive a small portion of the final sale at no extra cost to you.