Hello! Today, we are diving into the world of data scaling techniques. Imagine you are playing a game where you need to fit different shapes into matching holes. If your shapes vary greatly in size, it can be challenging. Similarly, in data analysis and machine learning, features (or columns) in your dataset may have vastly different scales. This can affect the performance of your analysis or model.
Our goal for this lesson is to understand two key data scaling techniques: Standard Scaling and Min-Max Scaling. By the end of this lesson, you'll be able to apply these techniques to scale features in a dataset, making them easier to work with.
Let's use the Titanic dataset to perform Standard Scaling on the age and fare columns.
Output:
Note: The Titanic
agecolumn contains missing values. Pandas’mean()andstd()skip missing values by default, so the scaling parameters are calculated only from non-missing ages. Missing ages will remainNaNafter scaling. Also,Series.std()uses the sample standard deviation by default, equivalent toddof=1, which can differ slightly from tools like scikit-learn’sStandardScaler, which uses population standard deviation.
