jaungiers / LSTM-Neural-Network-for-Time-Series-Prediction

LSTM built using Keras Python package to predict time series steps and sequences. Includes sin wave and stock market data
GNU Affero General Public License v3.0
4.82k stars 1.96k forks source link

Code for De-Normalization #60

Open Emuly opened 5 years ago

Emuly commented 5 years ago

Can someone write code for De-Normalization so I can plot predictions on real data values

marmartintsang commented 5 years ago

Same request here.

RickPang commented 5 years ago

Same request here.

ZionYuan commented 5 years ago

Same request here.

guillaume-chevalier commented 5 years ago

@alexbrillant We here have the demonstration of a good use-case for a NormalizationWrapper MetaStep object.

We should code a NormalizationWrapper (MetaStep) in Neuraxle that normalizes the data before sending it to a wrapped pipeline step, and that then denormalizes it before returning the results.

Inside that, the same normalization could be applied to y from the normalization values learned from x such that the wrapped neural network just sees normalized data and also predicts normalized data.

The same concept could go with a LogWrapper that would take the LogPlusOne of the values and also undo the transformation after.

Even further into this thinking, we could have a step that instead has a principal wrapped step, and also a list (or pipeline) of other steps to "apply" as preprocessing and then "unapply" as a reverse transformation after the processing is done to properly wrap the neural network. Let's call this a ReversiblePreprocessingWrapper.

Actually, I opened an issue here to do that, as we'll need it anyways: https://github.com/Neuraxio/Neuraxle/issues/59

kitt-th commented 5 years ago

Can someone write code for De-Normalization so I can plot predictions on real data values

the denormalization formula is given onthe altumingelligence article.... i could post the code here to do it in place where the normalization is done if you like, but it it very straightforward

hao940953596 commented 5 years ago

@kitt-th Can you write the code here? I really need it, thank you.

kitt-th commented 5 years ago

sure to do a reverse check - ie denormalisation, inside the normalisation function, do this

denormalized_col = [ ( float(window[0, col_i]) * (float(n) + 1 ) ) for n in normalised_col ]

(denormalisation func - Pi = Po*(Ni + 1) (from the article text)

jimfoo88 commented 4 years ago

I don't think it is possible to denormalise the predicted data with that formula. It will results in some values very close to 0. I suggest to change the normalisation to use MinMaxScaler from sklearn instead. You can denormalise using the invert function.

zhangzhang-vvv commented 4 years ago

I don't think it is possible to denormalise the predicted data with that formula. It will results in some values very close to 0. I suggest to change the normalisation to use MinMaxScaler from sklearn instead. You can denormalise using the invert function.

could you write this MinMaxScaler code here?thank you!!