Reference to non-existent field 'predictFcn'.
Mostra commenti meno recenti
I'm going to predict a new data using a SVM classification model which I created using the classification learner apps. After I export the model into workspace, I save the model into .mat file using command
save('trainedClassifier')
because I want to use the model to predict new data in my GUIDE program. And here is the code I use to predict new data using the model
Img = handles.Abu;
[m,n,~] = size(Img);
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
imshow(Img);
%Below is the code I use to create mask to determine ROI of the image
h = imrect(gca, [10 10 750 750]);
setResizable(h,false)
wait(h);
mask = createMask(h);
%Below is the code I used to extract feature
Mean = mean2(Img(mask));
Std = std2(Img(mask));
Variance = var (double(Img(mask)));
Kurtosis = kurtosis(double(Img(mask)));
%Below is the I use to predict new data
T = table(Mean, Std, Variance, Kurtosis);
trainedClassifier = load('trainedClassifier.mat');
yfit = trainedClassifier.predictFcn(T);
%Below is the code I use to display the result into edit text
set(handles.edit1, 'String', Mean);
set(handles.edit2, 'String', Std);
set(handles.edit3, 'String', Variance);
set(handles.edit4, 'String', Kurtosis);
set(handles.edit5, 'String', yfit);
but I'm getting error Reference to non-existent field 'predictFcn'. How to fix this problem ? Is it possible to use a model which created from the Classification Learner apps in a GUIDE program ?
1 Commento
Jahnavi Samal
il 23 Gen 2023
For me too getting the same error. Could u plz tell me how did u resolve it?
Risposte (1)
Jahnavi Samal
il 25 Gen 2023
Modificato: Jahnavi Samal
il 25 Gen 2023
0 voti
While saving the training model from classificationLearner app the model gets imported into the workspace with a variable name. Use that variable name with predictFcn after loading the saved trainedmodel .mat file It worked for me.
Categorie
Scopri di più su Custom Training Using Automatic Differentiation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!