Lesson Introduction

Hey there! Today, we're going to learn about feature scaling. You might be wondering, what is feature scaling, and why should we care? Simply put, feature scaling is like making sure all the ingredients in your recipe are measured in the same unit. Imagine trying to mix pounds of flour and teaspoons of salt without converting one to the other — it wouldn't make sense, right?

Our goal is to understand why feature scaling is crucial in machine learning and to learn how to do it using Python and a library called SciKit Learn.

What is Feature Scaling?
Example of Feature Scaling with `StandardScaler`

Let's create a small sample dataset to see how feature scaling works.

Python
import pandas as pd
from sklearn.preprocessing import StandardScaler, MinMaxScaler

# Sample dataset
data = {'Feature1': [1, 2, 3, 4], 'Feature2': [10, 20, 30, 40]}
df = pd.DataFrame(data)
print("Original DataFrame:")
print(df)

Output:

Original DataFrame:
   Feature1  Feature2
0         1        10
1         2        20
2         3        30
3         4        40

Before scaling, Feature1 ranges from 1 to 4, and Feature2 ranges from 10 to 40. Let's scale this dataset using StandardScaler.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal