machine-learningscikit-learntime-seriesminmaxstandardization

Shifting from StandardScaler to MinMaxScaler causes problem


I was using StandardScaler to standardize my time series data before putting it into the RNN. It has always worked. But now I shifted to MinMaxScaler instead. Everything works well except I cant inverse transform the data back again.

I get the following error when trying to inverse transform:

ValueError: Expected 2D array, got 1D array instead:
array=[0.03481037].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

Solution

  • It clearly states that your inputs are in 1D. So try changing it to 2D with the help of reshape function

    import numpy as np
    X = np.array(X).reshape(-1,1)
    y = np.array(y).reshape(-1,1)