How to update code so that future dates are used for forecsting?
이전 댓글 표시
Hi everyone
I am new to MATLAB. I have a code I got from a book I am reading. It separates the data into training and validation/testing sets. The code is forecasting based on the valdiation/testing set but that is still historical actual data. I want the code to give me predictions for the future and then I will compare the predictions against actual future values. How do I modify my code so I can get 10 future predictions? I am going to be importing the predictions into SQL Server so the format in MATLAB needs to allow me to import into a table in SQL Sever.
The desired layout is a 1 by 12 matrix:
[SYMBOL FORECAST_DATE_TIME DAY1 DAY2 DAY3 DAY4 DAY5 DAY6 DAY7 DAY7 DAY8 DAY9 DAY10]
I can add SYMBOL and FORECAST_DATE_TIME so I don't need help with that part.
Here is the code (just the parts used for the prediction):
n = length(CIV.COMPOSITE_IMPLIED_VOLATILITY);
nTrain = floor(0.8*n);
sTrain = CIV.COMPOSITE_IMPLIED_VOLATILITY(1:nTrain);
sTest = CIV.COMPOSITE_IMPLIED_VOLATILITY(nTrain+1:n);
sTestNorm = (sTest-mu)/sigma;
sTest = sTestNorm(1:end-1);
net = trainNetwork(xTrain.',yTrain.',layers,options);
yPred = predict(net,sTest.');
yPred(1) = yTrain(end-1);
yPred(2) = yTrain(end);
I want to keep the existing prediction but I want to add another one that is for future 10 days starting tomorrow. This is stock market data so there will be gaps (ie no trading happens on the weekends/holidays) so if actual dates are too trouble then having a generic "Day1", "Day2" etc label is enough. I can assign the actual dates in SQL Server when I process the data there.
Thank you
댓글 수: 1
답변 (1개)
Pratik
2024년 12월 10일
0 개 추천
Hi Manny,
The error of "Too many output arguments" occurs when a function you are trying to call expects fewer output arguments, than you have provided to it.
Please refer to this MATLAB Answer post for more information about the error:
From initial assessment it can be deduced that the 'predict' function needs to be checked. 'predict' function used here does not return state of the model. Please refer to the following documentation for more information:
댓글 수: 3
Manny
2024년 12월 10일
Pratik
2024년 12월 10일
Hi,
The predict function used in the code given in MATLAB example is of type 'dlnetwork' whereas from the error received I can see that your model is of type 'SeriesNetwork'. The predict function for 'dlnetwork' gives states as output however for 'SeriesNetwork' we just get the prediction.
To fix the issue, consider making the network using 'dlnetwork'.
Please refer to following documentation for more information:
Also consider refering to the documentation of 'SeriesNetwork' for more information about it's predict function:
Manny
2024년 12월 10일
카테고리
도움말 센터 및 File Exchange에서 Linear Predictive Coding에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
