How to predict values from machine learning model?

31 views (last 30 days)
Manny
Manny on 21 Feb 2024
Edited: Drew on 22 Feb 2024
Hi everyone
I am new to machine learning and MATLAB. I am not sure what I am doing wrong. I have a table of stock market data called CIV. The table has symbol, date, and CIV. See screenshot from workspace. I want to forecast by symbol and date. For example, for symbol ABC I want forecast for 10 days. For symbol DEF I want 10 day forecast. The underlying data for the symbols will be different b/c the symbols are different. Hopefully this makes sense. If not, I will clarify if needed. I was able to export the trainmodel. How do I tell it that I want to forecast 10 days starting from date X? I created an array of the dates to use for the forecast but I can't figure out how to use it. Here are the dates:
% CREATE ARRAY OF DATES THAT ARE USED FOR FORECASTING
T0 = datetime("today");
T1 = datetime(busdate(T0,1));
T2 = datetime(busdate(T1,1));
T3 = datetime(busdate(T2,1));
T4 = datetime(busdate(T3,1));
T5 = datetime(busdate(T4,1));
T6 = datetime(busdate(T5,1));
T7 = datetime(busdate(T6,1));
T8 = datetime(busdate(T7,1));
T9 = datetime(busdate(T8,1));
T10 = datetime(busdate(T9,1));
ForecastDates = [T1 T2 T3 T4 T5 T6 T7 T8 T9 T10];
Here is how I started the machine learning app:
Here is a screenshot of the variables in my workspace:
Thank you
  3 Comments
Manny
Manny on 21 Feb 2024
One more thing...
MATLAB tells me to use yfit = trainedModel.predictFcn(T) for forecasting but I cannot figure out how to give it an array of dates I created above. Any help is much appreciated.
Manny
Manny on 21 Feb 2024
Hi @KSSV. I entered what I showed in the first screenshot. I picked 'CIV' and then the app automatically picked the response and predictors. I only changed the training data field to 25. I used the learner app to train it.

Sign in to comment.

Answers (1)

Drew
Drew on 22 Feb 2024
Edited: Drew on 22 Feb 2024
The Classification Learner app is not specifically designed for working with time series. To analyze time series, there are several options depending on the requirements of your use case. Here are some of the options:
If this answer helps you, please remember to accept the answer.

Community Treasure Hunt

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

Start Hunting!