Difference between Standard scaler and MinMaxScaler

Chakra picture Chakra · Jul 9, 2018 · Viewed 23.4k times · Source

What is the difference between MinMaxScaler and standard scaler.

MMS= MinMaxScaler(feature_range = (0, 1)) ( Used in Program1)

sc = StandardScaler() ( In another program they used Standard scaler and not minMaxScaler)

Answer

Black Raven picture Black Raven · Nov 14, 2019

MinMaxScaler(feature_range = (0, 1)) will transform each value in the column proportionally within the range [0,1]. Use this as the first scaler choice to transform a feature, as it will preserve the shape of the dataset (no distortion).

StandardScaler() will transform each value in the column to range about the mean 0 and standard deviation 1, ie, each value will be normalised by subtracting the mean and dividing by standard deviation. Use StandardScaler if you know the data distribution is normal.

If there are outliers, use RobustScaler(). Alternatively you could remove the outliers and use either of the above 2 scalers (choice depends on whether data is normally distributed)

Additional Note: If scaler is used before train_test_split, data leakage will happen. Do use scaler after train_test_split