Scaling
Learn how to scale data with scikit-learn.
We'll cover the following...
Scaling means transforming numerical variables so that they have a similar StandardScaler, MinMaxScaler, and RobustScaler.
To better illustrate this point, let’s take a look at how some algorithms can be impacted by the scale of the variables (this code is just for illustration purposes; there is no need to memorize it):
Notice how accuracy has drastically increased after scaling the variables. This happens with certain algorithms that are sensitive to the scale of variables. Let’s see some of the methods we can use to address this.
The StandardScaler method
The StandardScaler method transforms each numerical variable so that it has a mean of zero and a standard deviation of one. This is achieved by subtracting the mean of each variable from each value and then dividing by the standard deviation:
where
The following code demonstrates how to use the ...