I have a dataset with 2 features (price & volume) & 1 predicted variable (price) and use LTSM model to predict next price based on the previous set of prices.
First I scale the dataset:
#Scale the data
scaler = MinMaxScaler(feature_range=(0,1))
scaled_data = scaler.fit_transform(dataset)
Finally I want to unscale it:
#Get the models predicted price values
predictions = model.predict(x_test)
predictions = scaler.inverse_transform(predictions)
But this doesn't work and I get this error:
ValueError: non-broadcastable output operand with shape (400,1) doesn't match the broadcast shape (400,2)
What this error means is that: you have scaled two features i.e. price and volume of shape (400,2), however, at the time of unscaling you are giving only the predicted price in shape (400,1)
A simple solution is to use two separate scalers - one that will unscale the response variable i.e. price (and the associated input feature, again the price), and second one for the rest of the features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With