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 Center および File ExchangeClassification Learner App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by