1
$\begingroup$

Suppose I have list like this:

dataset = [2,3,5,7,11,13]

# Split x_train where x_window is 3
x_train = [
[2,3,5],
[3,5,7],
]

# Split y_train where y_window is 2
y_train = [
[7,11],
[11,13],
]

Shall I normalize with Minimax scaling for entire dataset first before splitting train set? If so, then the min value for entire dataset is 2 while the max value for entire dataset is 13.

If no, shall I normalize the every x_train and every y_train? If so, then the min value is depends on value in element itself, for example x_train[0] min value is 2 while x_train[0] max value is 5.

I need to put it to the architecture of LSTM

model.add(LSTM(input=(x_train.shape[1],1))
model.add(Dense(y_train.shape[1]))
$\endgroup$

1 Answer 1

2
$\begingroup$

To answer your question:

  • If you have outliers in your dataset then use RobustScalar as it can handle outliers. If no, then you can use Normalization or Standardization techniques.
  • Now, about when to use these, always use the normalization after you split the data. Why? Because we want our data to resemble like our test data and not our training data. If our validation data looks like or has the same features as training data, then your model will overfit and won't generalize well to your test set.
  • One last thing, about normalizing the "y_train". Instead of normalizing, just remove the outliers or impute them with mean or median values of y_train. And use normalization techniques like np.log1e(y_train) or np.sqrt(y_train). Why? Because these methods can perform very well. And also it is easy to generate back your original data from these methods. I Hope I answered your questions.
$\endgroup$

Your Answer

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

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