MATLAB Answers

How to extract the predicted response from the Regression Learner App ?

5 views (last 30 days)
After training a model using the Regression Learner App, how to extract the predicted response (values)?
Thank you.

  0 Comments

Sign in to comment.

Accepted Answer

Bhargavi Maganuru
Bhargavi Maganuru on 12 Sep 2019
To extract the predicted response for trained data,
Select Response plot and click Export plot to Figure. It creates a figure from the plot.
To save data to workspace from the figure select File>Save Workspace. This creates a .mat file.
Load .mat file and get predicted responses
a=load('responses.mat');
PredictedResponses=a.yfit;
Hope this helps!

  3 Comments

Pierre Guy
Pierre Guy on 13 Sep 2019
First of all, thank you very much for your time. Following your reply, I performed new attempts to extract the predicted responses, which remained unsuccessful.
1) you said I shoud: click Export plot to Figure, however there is no such option in the regression learner app (in my case: SVM regression on Matlab R2018a).
Instead, in the Export section, I selected Export Model that exports model to the workspace as a structure containing a regression model object. From there, the two lines code you provided don't work.
2) I don't quite understand your piece of code, in particular, what is 'responses.mat' in a=load('responses.mat')?
I'm seeking further guidance.... Again, thank you very much.
Best regards,
Bhargavi Maganuru
Bhargavi Maganuru on 13 Sep 2019
Solution which I have mentioned is for MATLAB R2019a version.New feature Export plot to Figure in R2019a, creates figure from plot.
While saving the data to the workspace, I stored the file as 'responses.mat', which containes true and predicted responses of training data.
As there is no feature Export plot to Figure in R2018a, you can export model using Export Model and predict the responses of the training data.
Suppose you export the model as trainedModel to the workspace you can do following
PredictedReponses=trainedModel.predictFcn(T) %where T is the Training data

Sign in to comment.

More Answers (0)

Sign in to answer this question.