File Exchange

image thumbnail

Time Series Prediction

version 1.3.92 (147 KB) by Abolfazl Nejatian
time series prediction by use of Deep learning and shallow learning algorithm

278 Downloads

Updated 09 Feb 2021

View Version History

View License

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
-------|| If you enjoyed, Please like and subscribe my channel.🙏 ||--------
some other results with the CNN and LSTM network.

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
||-----------------------------------************----------------------------------------||

Cite As

Abolfazl Nejatian (2021). Time Series Prediction (https://www.mathworks.com/matlabcentral/fileexchange/69506-time-series-prediction), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (52)

xi ling

Bitcoin price prediction 2025: It will be $1 Million
After hitting an all-time high this year, many are afraid that China's latest permissions have actually created Bitcoin to topple. Crypto fostering reducing worldwide is a legitimate concern.So just how to ensure the Bitcoin price prediction 2025, this is an essential inquiry.

Others think that there's space for development in this market and also see a brilliant future in advance. Will Bitcoin struck $1 million by 2025? Allow's discover why this Bitcoin forecast 2025 isn't as difficult as several of the pessimists might believe.

Why Bitcoin Could Strike $1 Million By 2025?
The existing state of the cryptocurrency market is absolutely unstable. This isn't always a poor point. Bitcoin's worth has actually blown up given that its intro as well as it has actually held fairly stable throughout.

As Bitcoin exchanges present margin trading as well as various other attributes, it's proper to see if it will certainly remain to enhance. This is the vital distinction in between what any kind of Bitcoin price prediction 2020 might have held contrasted to 2021.

As even more individuals are presented to Bitcoin, this need will just enhance. Many think that it might be among the very first cryptocurrencies to really attain mass fostering. We'll see a high cost whether or not China's restriction influences it if this takes place.

The cryptocurrency market remains in a really various area than it was even 3 or 4 years earlier. In 2017 and also very early 2018, it was loaded with ICOs that used high go back to capitalists. Due to the number of rip-offs, self-confidence in ICOs has actually lessened. Capitalists are transforming back to staples of Bitcoin, Bitcoin Money, and also Ethereum. A Bitcoin cash money rate forecast at that time would certainly have been a lot various to one made today based upon these aspects alone.

Bitcoin price prediction 2025
In 2021 we can anticipate the rate to raise because of business like Bitmain concentrating on developing mining ASICs. With the intro of brand-new attributes like Lightning Network and also wise agreements, there's a whole lot to be delighted concerning relating to arising blockchain innovation.

This might be one of the largest years for cryptocurrency financial investment if these firms prosper in establishing their items successfully. With this much possibility, it's not unreasonable to make a cost forecast of $1 million for 2025.

Why Bitcoin May Battle To Strike $1 Million By 2025?
Bitcoin isn't as sensible or liquid as Visa as well as Mastercard are for daily repayments.

Various other cryptocurrencies have actually obtained a lot more traction than Bitcoin in recent times, especially as the cryptocurrency ecological community has actually developed. It ends up being significantly challenging to anticipate which altcoins will certainly do well as even more go into the marketplace.

Due to the fact that there is no background to go by, spending is testing when dealing with brand-new modern technology. Each cryptocurrency has its very own staminas and also weak points, and also special facets that make it stick out. Bitcoin simply does not have the very same "awesome application" that can eventually press it over the remainder.

As Bitcoin proceeds to progress as well as expand, the market is bound to locate a method. Simply put, it will not be long prior to we begin seeing brand-new altcoins which use far better functions than Bitcoin itself has today.

Bitcoin does not have the functions of more recent cryptocurrencies, such as Ethereum's assistance for clever agreements. If Bitcoin obtains left behind by cryptos developed with exceptional energy and also modern technology, it will certainly be no shock.

Why 2021 Could Be The Most Effective Year For Crypto?
2021 is one more year of mass fostering. Business like Facebook are releasing their very own exclusive cryptocurrencies and also blockchains are making it possible for peer-to-peer deals. We can anticipate passion to expand amongst a bigger customer base that hasn't embraced previous cryptocurrencies currently.

Business that incorporate crypto right into their systems require to concentrate on user-friendliness as well as protection in order to develop trust fund. Ideally, this is something that business like Facebook as well as Apple can accomplish in the coming months.

The cryptocurrency market is still young as well as it's clear that there will certainly be extra low and high prior to it develops. This does not indicate that Bitcoin will not strike $1 million by 2025. There's a likelihood it may occur despite the present state of the marketplace.

Mass fostering is vital to enhancing Bitcoin's appeal. It requires to be very easy for individuals to utilize and also comprehend the advantages of utilizing cryptocurrency over fiat money. We might see Bitcoin's worth expand substantially if business like Facebook can be successful in this. If their items are filled with pests or safety and security problems, just time will certainly inform just how effective they'll be.

What Regarding Bitcoin Gold?
This is where our Bitcoin Gold price prediction enters the equation. Bitcoin Gold is a lot more effective and also is the favored selection for smaller sized as well as much more regular purchases.

Bitcoin Gold is a fascinating cryptocurrency that's making a huge effect. While it isn't as extensively recognized or utilized as a lot, you can anticipate points to transform in the future. It resembles Litecoin as well as has actually been around because October 2017, when it forked from Bitcoin.

When just very early adopters were interested in spending in brand-new cryptocurrencies, it was birthed. Both money are ASIC-resistant. making them extra attractive for financiers that desire much faster deal times as well as reduced costs. For these factors we believe it's not unreasonable to anticipate Bitcoin Gold to strike $500 by 2025.

Bitcoin Gold likewise keeps optimal block dimension limitations like its larger relative finishes with greater miner benefits (presently 12). Any individual can extract it without specialized equipment from recognized makers such as Bitmain or KnCMiner. They do not require any type of previous experience with blockchain modern technology to extract it either.

The need for Bitcoin Gold will certainly raise in time many thanks to its distinct functions contrasted to various other comparable tasks. This will certainly apply throughout all elements of the marketplace also, despite its function.

Bitcoin Rate Forecast 2021 And Also Verdict
Bitcoin prediction 2025
We're positive that Bitcoin might quickly rise previous $100k by December or very early January. It's completely practical to insist that Bitcoin can getting to brand-new elevations. It has actually struck $62k currently, as well as striking the $100k landmark on its trip to $1 million by 2025 is sensible.

Bitcoin's development capacity is surprising. It has the prospective to expand by 18 times from $20k to $100k as well as even 40 times in ten years. This suggests that Bitcoin might strike a cost of approximately $4 million prior to 2025. There is a really high possibility that it might strike a rate of approximately $3 million or even $2.5 million by 2025.

ia

@Abolfazl Nejatian You are a perfect person, thank you very much for your help ..

ia

very useful and useful work, thank you very much

NN

Very helpful and it is a great contribution
Thank you very much for the code

NN

Abolfazl Nejatian

Dear @NN

in order to get the future forecast, you need to use second or third version of code( based on your work) from links above.

best wishes.

NN

@Abolfazl Nejatian The results variable is not present in the workspace after executing the file.Only data and opt files are there.
Please advise how to get forecasted output values.

NN

Manuela Panoiu

Error on Training LSTM Network
Reference to non-existent field 'BiLSTM'.

Jorge Moya

Reference to non-existent field 'BiLSTM'

Roberto Gonzalez

It's a routine with an excellent technicality. A great contribution for those of us who work with time series and want to explore the Neural Network method. Congratulations!

BOUREGBA Hicham

thanks

jamesFoxMM James

Dear Abolfazl,
i got my results and the forecasting code was very useful for me.
thank you so much for your code and help.

BOUREGBA Hicham

fasrah arif

Ainnur Farah Izzati

Paolo Musto

@Muhammad Abdullah
try changing this
opt.executionEnvironment = 'gpu';

from gpu to cpu

Ilker Golcuk

Muhammad Abdullah

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!

Muhammad Abdullah

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

SOILIHI Mohamed

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

Masoud Rezaei

MUHAMMAD SARFRA

hi I think it is a well written code, have you performed forecasting of solar/wind energy ?

Abolfazl Nejatian

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.

Vitaly Kheyfets

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%.

Fabio VArgas

excellent job. tks

Jorge Moya

I faced a problem
Reference to non-existent field 'XTs'.

Parisa Zomorodian

Valeri Disko

Aman Swaraj

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);

Attilio Pittelli

What about the forecasting data? where could i see those?

Siamak

Gabriyel Wong

Same question as Ali, please include the xlsx sample data file. It's missing in the zip downlaod. Thanks!

Chairat Kewcharoen

Alexander Hosovsky

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.

Adrian Sulkowski

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.

FengJin jin

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);

Dong Yao

weiwei duan

Md. Tanjin Amin

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.

Md. Tanjin Amin

Abolfazl is a nice and helping person. He tries to help with the code.

Parisa Zomorodian

Amelia

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

Hussein Sharadga

Ali

data file (.xlsx) ? Can anyone upload data file as a reference?

Utkarsh Singh

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

Victor Plaza

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.

marzieh

Utkarsh Singh

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!

Abolfazl Nejatian

dear @Eduardo Santos
by downloading the updated code, you can find output data on the workspace in 'results' variable.
best wishes
Abolfazl Nejatian

Eduardo Santos

How may I see the forecast data? I mean... How do interpret the script output data?

inturi srivani

MATLAB Release Compatibility
Created with R2018b
Compatible with R2018a to R2018b
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!