Reference to non-existent field 'predictFcn'.

조회 수: 2 (최근 30일)
Yogi Jefani
Yogi Jefani 2017년 8월 2일
편집: Jahnavi Samal 2023년 1월 25일
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
Jahnavi  Samal
Jahnavi Samal 2023년 1월 23일
For me too getting the same error. Could u plz tell me how did u resolve it?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jahnavi  Samal
Jahnavi Samal 2023년 1월 25일
편집: Jahnavi Samal 2023년 1월 25일
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.

카테고리

Help CenterFile Exchange에서 Classification Learner App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by