In the "Export Regression Model to Predict New Data" under the "Deploy Predictions Using MATLAB Compiler", what does cartable.mat stands for?

I am using regression app for developing machine learning algorithm. After I have developed model, I would like to create a MATLAB app for it. When I went through the documentation, I was able to find a help (https://in.mathworks.com/help/stats/export-regression-model-to-predict-new-data.html). Under this in "Deploy Predictions Using MATLAB Compiler", they have suggested some steps. But on trying those steps, I am getting error?
The step is that they have asked to create a function and then run it
function ypred = mypredict(tbl)
%#function fitrtree
load('mymodel.mat');
load('cartable.mat')
ypred = trainedModel.predictFcn(cartable)
end
But, when i run the function, I am getting an error.
error using load
Unable to read file 'cartable.mat'. No such file or
directory.
Error in mypredict (line 4)
load('cartable.mat')
In the documentation it is mentioned that, "It must also have a pragma, so the compiler recognizes that Statistics and Machine Learning Toolbox™ code is needed in the compiled application. This pragma could be any function in the toolbox." I am not understanding this part. What does it mean by any function in the toolbox. What is cartable.mat?
How to overcome this error?

3 Comments

The two .mat filenames in the function are just placeholders/examples presuming for the purpose of demonstration that the user (you) had saved the model by the preceding
save mymodel trainedModel
which created the 'mymodel.mat' file contained the trained model object trainedModel that had been developed and saved by the previously described steps of using the app.
'cartable.mat' is just the dataset that is being used for that model to predict new responses from the model...again, it's presumed to be for that preceding example.
You will use whatever file names you have created for the two steps of the model and any data for which want to use the model.
The pragma is the
%#function fitrtree
line in the function...it's immaterial what the function is just copy this line verbatim.
Your explanation worked perfectly well. But i got landed in no mans land with another issue. The MATLAB compiler is not available for MATLAB student licence.
So I cannot anyway use this code. :(

Sign in to comment.

Answers (1)

I am getting the below error in matlab command line;
function ypred = mypredict(tbl)
Error: Function definition not supported in this context. Create functions in code file.
what is 'tbl'?

Asked:

on 15 Jun 2019

Answered:

on 10 Dec 2019

Community Treasure Hunt

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

Start Hunting!