Hope you are doing well,
time-series data preparation video tutorial part 1,
https://youtu.be/gKT8HSoJ0cE
code and results output, part 2,
https://youtu.be/G1kcWoXZE6A
Monthly closing prices of S&P500
https://ibb.co/y5hHr71
Monthly Australian Sales of Red Wine Jan1980Jul1995
https://ibb.co/4NLwqhM
yearly US accidents
https://ibb.co/9Zw0brX
Global Ice Volume
https://ibb.co/8xSt4Mg
you can download the first version of the code from here(current page):
https://www.mathworks.com/matlabcentral/fileexchange/69506-time-series-prediction
the second version of code(Future Forcast with MLP and LSTM) from here:
https://dataanalysisresearch.com/product/timeseriesprediction_lstm-m/
the third version of code(Future Forcast with MLP, LSTM, and CNN) from here:
https://dataanalysisresearch.com/product/timeseriesprediction_cnn_lstm/
and this is my website you can find useful information about the time series from there:
https://dataanalysisresearch.com/
If you have questions or would like to improve the code, don't hesitate
to mail me: abolfazl.nejatian@gmail.com
Best wishes,
Abolfazl Nejatian
||-----------------------------------************----------------------------------------||
this is also
time-series prediction with Bayesian Hyper Parameter Tuning
https://www.mathworks.com/matlabcentral/fileexchange/87137-lstm-time-series-prediction-with-bayesian-optimization
||-----------------------------------************----------------------------------------||
Abolfazl Nejatian (2021). Time Series Prediction (https://www.mathworks.com/matlabcentral/fileexchange/69506-time-series-prediction), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
thanks
Dear Abolfazl,
i got my results and the forecasting code was very useful for me.
thank you so much for your code and help.
@Muhammad Abdullah
try changing this
opt.executionEnvironment = 'gpu';
from gpu to cpu
Dear Mr. Abolfazi, Thanks for sharing the file, I have reviewed it, and you done the excellent work, very precise, accurate and written in professional way. welldone!
Dear Mr. Abolfazi, I have tried to execute your free version of the code, and it gives the error message "Reference to non-existent field 'BiLSTM'.
". You have done the great work on it, can you plz share the code with future prediction? I have sent you an email, plz check, thanks and best wishes
Dear Mr Abolfazl, the third code is very interesting (TimeSeriesPrediction_Forcasting_CNN_LSTM), I have executed it and I find it satisfactory.
However for the predictions it is also necessary to have the third code. Thank you and Best wishes Mr Abolfazl Nejatian
hi I think it is a well written code, have you performed forecasting of solar/wind energy ?
dear @Vitaly Kheyfets
Thank you for your helpful comment.
Now you can also see the prediction in the description section video.
and download it from my web site.
This is a very nicely written code, but I don't think this approach is correct for time series forecasting. I'm not sure a NN is doing much here. The code is basically just training an AR model, but AR models require that the time series is stationary. If, instead of evaluating model performance by regression, one constructs a confusion matrix to compare daily stock increase vs. decrease, the prediction accuracy is at around 50%.
excellent job. tks
I faced a problem
Reference to non-existent field 'XTs'.
I faced a problem
Reference to non-existent field 'XTs'.
Error in timeSeriesPrediction_1>evaluateNet (line 275)
TestOutputs = (predict(results.Net,data.XTs,'MiniBatchSize',opt.miniBatchSize));
Error in timeSeriesPrediction_1 (line 72)
results = evaluateNet(results,data,opt);
What about the forecasting data? where could i see those?
Same question as Ali, please include the xlsx sample data file. It's missing in the zip downlaod. Thanks!
The code is nice - as mentioned before the calculation of mean and std should be applied only to train data. It could also be improved by adding selectable multiple steps ahead predictions capability into general parameters section of the code.
Hi, I'm begginer in Matlab.
How I can use the code to forecast the future time series? I can read test data, but I want find 10-12 future series.
in 'results' variable I see only compare beetween targets and outputs for test data.
Hello, the following error occurred while I was running
The function or variable 'sequenceInputLayer' is not defined.
Error LSTMArchitect (line 14)
sequenceInputLayer(inputSize)
Error main4 (line 44)
Opt = LSTMArchitect(opt);
Hello, I feel the code needs to be
changed. It seems that it can read the test data and tune the model accordingly. It should not be in a practical case.
Abolfazl is a nice and helping person. He tries to help with the code.
Dear Abolfazl,
Thank you for sharing the code, but i have a problem when trying to run it, i have this error massage :
Struct contents reference from a non-struct array object.
Error in timeSeriesPrediction (line 44)
if ~data.isDataRead
could you help please.
thanks in advance
data file (.xlsx) ? Can anyone upload data file as a reference?
i discussed the code with other experts and I can confirm that Victor Plaza is right. The code assumes that the mean and deviation for test set is known, which is not possible and unsuitable for a real-time forecasting
I think your code is biased from the beginning. You are normalizing the data previously to split it into training and testing.
That implies you know the mean and the standard deviation of the testing set, what is false. You need to calculate these measures for the training set, what is what you will have in online processing, and later apply it to the testing set.
Calculating them over the whole data set allows the LSTM to access data that is actually unavailable.
Dear Abolfazl,
Thank you for posting this code. I have a question regarding the possibility of multistep ahead predictions using this code.
I see that the delays can be used to train the LSTM on several step ahead data. The test set is also prepared in a similar manner. It seems that the predictions are N- step ahead where N would be max(Delays)+1. But when i observe the results in my case, it does not seem to be the case.
I would kindly request you to give an interpretation (with respect to prediction horizon) for the plot showing 'all data'.
I have a time series with of length 720 samples with 30 sec interval between two consecutive samples. I am basically trying to: (i) get predictions for one hour ahead (ii) given the time series, predict 'n' further steps of that series.
Thank you for your time!
dear @Eduardo Santos
by downloading the updated code, you can find output data on the workspace in 'results' variable.
best wishes
Abolfazl Nejatian
How may I see the forecast data? I mean... How do interpret the script output data?