How to re-run a generated code from regression learner?

3 visualizzazioni (ultimi 30 giorni)
Hello,
I have trained and generated codes on regression learner and nntool. Then when I try to run any one of them later, it always show error.
How can i solve this issue?
Below attached is the error image from re-running a trained regression model.
Thanking in advance

Risposte (1)

Image Analyst
Image Analyst il 17 Nov 2021
I just export the model in Regression Learner into a variable called trainedModel. Then I store the trainedModel variable into a file called trainedModel.mat like this:
save('trainedModel.mat', 'trainedModel');
Then to load your model I do this:
s = load('trainedModel.mat');
trainedModel = s.trainedModel
In the command window it will tell you how to use it by calling the predict() function. So I then make up a table of predictors and pass it in:
%==========================================================================================================================
% HERE IS WHERE WE ACTUALLY MAKE THE PREDICTIONS FROM THE INPUT DATA!
% Estimate the Human scores by feeding the Image Analysis (Artificial Intelligence)
% numbers into the model.
predictedAIResponse = trainedModel.predictFcn(tPredictors);
% Stitch both side by side so we can inspect both scores conveniently in the Variable Editor panel.
bothScores = [predictedAIResponse, trueHumanResponse];
%==========================================================================================================================
trueHumanResponse is my ground truth values that I used for training -- the "true" values we are trying to model. predictedAIResponse is the estimated human values predicted from the model exported from the Regression Learner app and read back into our custom program.
  2 Commenti
Mehbubul Haque
Mehbubul Haque il 17 Nov 2021
Hello, thanks for the reply, it doesn't work for me, shows errors.
>> Reference to non-existent field 'trainedModel'.
or
>> Error using save
Variable 'trainedModel' not found.
Image Analyst
Image Analyst il 17 Nov 2021
When you're in Regression Learner, and you clicked the Export Model button on the tool ribbon, and you said to create a variable called trainedModel, did you see it appear in the workspace as a new variable? You should have. Calling save() won't work if you don't have that variable there. Did you in fact actually click the Export Model button or not?

Accedi per commentare.

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by