18
$\begingroup$

I have a feature vector with One-Hot-Encoded features and with continous features.

How can I decide now, which data I shall scale with StandardScaler and which data scale with MinMaxScaler? I think I do not have to scale the one-hot-encoded anyway because they are already between 0 and 1.

(I use afterwards a MLPClassifier)

$\endgroup$
1
  • 4
    $\begingroup$ Rule of thumb: Use StandardScaler for normally distributed data, otherwise use MinMaxScaler. $\endgroup$ Commented Jan 14, 2019 at 16:06

3 Answers 3

13
$\begingroup$

StandardScaler and MinMaxScaler are more common when dealing with continuous numerical data.

One possible preprocessing approach for OneHotEncoding scaling is "soft-binarizing" the dummy variables by converting softb(0) = 0.1, softb(1) = 0.9. From my experience with feedforward Neural Networks this was found to be quite useful, so I expect it to be also benefitial for your MLPClassifier.

StandardScaler is useful for the features that follow a Normal distribution. This is clearly illustrated in the image below (source).

enter image description here

MinMaxScaler may be used when the upper and lower boundaries are well known from domain knowledge (e.g. pixel intensities that go from 0 to 255 in the RGB color range).

$\endgroup$
12
$\begingroup$

In "Python Machine Learning" by Raschka the author provides some guidance on page 111 when to normalize (min-max scale) and when to standardize data:

Although normalization via min-max scaling is a commonly used technique that is useful when we need values in a bounded interval, standardization can be more practical for many machine learning algorithms. The reason is that many linear models, such as the logistic regression and SVM, [...] initialize the weights to 0 or small random values close to 0. Using standardization, we center the feature columns at mean 0 with standard deviation 1 so that the feature columns take the form of a normal distribution, which makes it easier to learn the weights. Furthermore, standardization maintains useful information about outliers and makes the algorithm less sensitive to them in contrast to min-max scaling, which scales the data to a limited range of values.

$\endgroup$
-3
$\begingroup$

StandardSCalar changes the shape of data while keeping data into range of 0 and 1. It can eliminate the outliers(which sometimes provides some useful info). NOTE: Do not remove all outliers until you do not have domain knowledge sbout them.

MinMaxScalar() do not changes the shape of data, while it also keeps the data into range of 0 and 1. It will do it for minimum number of features required.

$\endgroup$
1
  • $\begingroup$ Just for those coming here... StandardScaler does not change the shape of the data. The transformation is bijective and monotonic. The range of the resulting data will never be included between 0 and 1. The transformation removes the mean and scale the data with the standard deviation. As a result, the resulting data has 0 mean and takes both positive and negative values, the scaling makes it not that big. That's very important. For instance, never use a sigmoid for the last activation function of an auto-encoder which takes a standardized data as input. Otherwise, you're going to underfit. $\endgroup$
    – Mistapopo
    Commented Jul 30 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.