45
votes
Accepted
What is a good way to transform Cyclic Ordinal attributes?
The most logical way to transform hour is into two variables that swing back and forth out of sync. Imagine the position of the end of the hour hand of a 24-hour clock. The ...
- 6,778
39
votes
Accepted
Ways to deal with longitude/latitude feature
Lat long coordinates have a problem that they are 2 features that represent a three dimensional space. This means that the long coordinate goes all around, which means the two most extreme values are ...
- 9,248
26
votes
Accepted
How to scale an array of signed integers to range from 0 to 1?
This is called unity-based normalization. If you have a vector $X$, you can obtain a normalized version of it, say $Z$, by doing:
$$Z = \frac{X - \min(X)}{\max(X) - \min(X)}$$
- 543
22
votes
Feature Transformation on Input data
We love the normal form
In most cases we try to make them act like normal. Its not classifiers point of view but its feature extraction view!
Which Transformation?
The main criterion in choosing a ...
- 331
22
votes
Accepted
Should one hot vectors be scaled with numerical attributes
Once converted to numerical form, models don't respond differently to columns of one-hot-encoded than they do to any other numerical data. So there is a clear precedent to normalise the {0,1} values ...
- 28.1k
20
votes
Accepted
Why do we convert skewed data into a normal distribution
You might want to interpret your coefficients. That is, to be able to say things like "if I increase my variable $X_1$ by 1, then, on average and all else being equal, $Y$ should increase by $\beta_1$"...
- 3,352
16
votes
Accepted
Data scaling before or after PCA
I once heard a data scinetist state at a conference talk: "Basically, you can do what you want, as long as you know what you are doing."
This also applies here. The more statistically sound way ...
- 299
12
votes
Zero Mean and Unit Variance
The questions of whether and why it's important, depends on the context.
For gradient boosted decision trees, for example, it is not important - these ML algorithms "don't care" about monotone ...
- 1,187
12
votes
When should I use StandardScaler and when MinMaxScaler?
StandardScaler and MinMaxScaler are more common when dealing with
continuous numerical data.
One possible preprocessing approach for OneHotEncoding scaling is "soft-binarizing" the dummy ...
- 526
10
votes
When should I use StandardScaler and when MinMaxScaler?
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 ...
- 5,230
8
votes
Accepted
Should I rescale tfidf features?
The most accepted idea is that bag-of-words, Tf-Idf and other transformations should be left as is.
According to some: Standardization of categorical variables might be not natural. Neither is ...
- 3,320
8
votes
Accepted
How to give a higher importance to certain features in a (k-means) clustering model?
You cannot really use k-means clustering if your data contains categorical variables since k-means uses Euclidian distance which will not make a lot of sense with categorical variables. Check out the ...
- 1,206
7
votes
Accepted
When should I NOT scale features
Scaling often assumes you know the min/max or mean/standard deviation, so directly scaling features where these information is not really known, can be a bad idea.
For example, clipped signals may ...
- 3,448
6
votes
Normalized output of machine learning
First you do not always need to normalize (standardize) the input vectors (feature vectors), sometimes is good, sometimes is bad. In general you scale your feature vector when the magnitude of a ...
- 2,186
6
votes
Accepted
Do Clustering algorithms need feature scaling in the pre-processing stage?
Clustering algorithms are certainly effected by the feature scaling.
Example:
Let's say that you have two features:
weight (in Lbs)
height (in Feet)
... and we are using these to predict whether ...
- 76
6
votes
Linear Regression and scaling of data
You can't really talk about significance in this case without standard errors; they scale with the variables and coefficients. Further, each coefficient is conditional on the other variables in the ...
- 171
6
votes
Data scaling before PCA: how to deal with categorical values?
You can not use PCA, or at least it is not recommended, for mixed data. It is best to use Factor analysis of mixed data. You are lucky that Prince is a Python package that covers all data scenarios, ...
- 4,108
6
votes
Accepted
What are some situations when normalizing input data to zero mean, unit variance is not appropriate or not beneficial?
A detailed answer to the question can be found here.
[...]are there times when it is not appropriate or not beneficial?
Short answer: Yes and No. Yes in the terms, that it can significantly ...
- 458
6
votes
When do we scale features and should it be done to label encoded features?
You should not use Label Encoding for Categorical data unless there is a known ranking and that also in the specified ratio between the level values.
In this case, the model will assume 10 as 2 times ...
- 5,404
6
votes
Accepted
feature scaling xgbRegressor
You're also scaling $y$, then of course you are getting lower error. That question was regarding scaling $X$.
The same model will have very different error metrics when units on $y$ are changed: if I ...
- 5,921
5
votes
Do Clustering algorithms need feature scaling in the pre-processing stage?
Yes. Clustering algorithms such as K-means do need feature scaling before they are fed to the algo. Since, clustering techniques use Euclidean Distance to form the cohorts, it will be wise e.g to ...
5
votes
Feature scaling
You should apply the normalization only on your training dataset. Your test set should be kept completely separate and should be used only when your final model has been chosen. If you use include the ...
- 256
5
votes
Accepted
How to use the same minmaxscaler used on the training data with new data?
You are refitting scaler_x on your test set, which you don't want. Change this line:
xaa = scaler_x.fit_transform(xaa)
to
<...
- 259
5
votes
Accepted
Is it better to use a MinMax or a Log Return normalization to predict stock price movements?
Log returns are symmetric compared to percentage change. log(a/b) = - log(b/a) and this (less skewness), in theory, leads to better results for most models (linear ...
- 1,229
5
votes
How to handle features with very broad range
I suggest to try a log transformation. This has two potential benefits:
The range of x values becomes smaller
Your transformed data might be closer to resemble a normal distribution (only relevant ...
- 5,230
5
votes
Accepted
How does scaling affect Logistic Regression?
It affects anything optimized by a form of gradient descent, because it affects the relative scale of the dimensions of the input. If A is generally 1000x larger than B, then changing B's coefficient ...
- 6,515
5
votes
Accepted
Does the performance of GBM methods profit from feature scaling?
Scaling doesn't affect the performance of any tree-based method, not for lightgbm, xgboost, catboost or even a decision tree.
This post that elaborates on the topic, but mainly the issue is that ...
- 5,921
5
votes
Model performance worsens after Cross Validation
With only 210 samples the difference might be caused by your train and test data not being from the same underlying distribution. That is, using holdout-CV to estimate model performance on such a ...
- 5,230
4
votes
How to scale an array of signed integers to range from 0 to 1?
Find the largest positive number and the smallest (most negative) number in the array.
Add the absolute value of the smallest (most negative) number to every value in the array.
Divide each result by ...
- 141
4
votes
Accepted
PCA and maintaining relationship with target variable
The short answer is that the y_original and x_reduced are still connected to each other, so it is safe to train your data using y_original and x_reduced. While x_reduced is on a different scale, as ...
- 873
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
feature-scaling × 252machine-learning × 77
normalization × 52
scikit-learn × 41
feature-engineering × 34
python × 33
preprocessing × 32
neural-network × 26
lstm × 15
feature-selection × 15
deep-learning × 11
clustering × 11
statistics × 11
feature-extraction × 11
time-series × 10
regression × 10
data-cleaning × 9
classification × 8
keras × 8
dataset × 8
linear-regression × 8
data-mining × 7
data × 7
cross-validation × 6
feature-construction × 6