Project - Stock Closing Price Prediction using Deep Learning, TensorFlow2 & Keras

24 / 32

Feature Scaling

Let us then use MinMaxScaler, a module from sklearn library to scale the values into the range of 0 and 1. More about it here

We shall do this feature scaling as follows:

  • Use fit_transform to transform features by scaling each feature. We shall do this fitting on the train data train_data.

  • Then, use the transform method on the same scaler to transform the values of val_data and test_data.

INSTRUCTIONS
  • Import MinMaxScaler from sklearn.preprocessing

    from sklearn.preprocessing import << your code comes here >>
    
  • Get the MinMaxScaler object scaler and put feature_range=(0,1).

    scaler = << your code comes here >>(feature_range=(0, 1))
    
  • Use fit_transform method of scaler to apply feature scaling on train_data. Store the result in train.

    train = scaler.<< your code comes here >>(train_data)
    
  • Use transform method of scaler to apply feature scaling on val_data. Store the result in val.

    val = scaler.<< your code comes here >>(val_data)
    
  • Use transform method of scaler to apply feature scaling on test_data. Store the result in test.

    test = scaler.<< your code comes here >>(test_data)
    
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...