Scaling

This kind of transformation can be applied to numerical features only.

For example, in the Titanic data, the Age feature can reach 100, but the household income may be in millions. Some models are sensitive to the magnitude of values, so scaling such features will help those models perform better. Also, scaling can be used to squash a variable's values to be within a specific range.

The following code will scale the Age feature by removing its mean from each value and scale to the unit variance:

# scale by subtracting the mean from each value
scaler_processing = preprocessing.StandardScaler()
df_titanic_data['Age_scaled'] = scaler_processing.fit_transform(df_titanic_data['Age'])
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset