Missing value for predict in Classification Learner App

Hi, I have a question. I did the Classification Step with the training step. After trainning I use test data in the App, I have added the data data into Data Test set, but there is one error it said Missing value for predict Power. Can anyone help me, cause I think my data is not missing anything
% TRAINING
trainingData=readtable("ClassificationData2.xlsx")
% The first 4 columns are the inputs.
tPredictors = trainingData(:, 1:2);
% The last column is the "answer/ground truth".
tResponse = trainingData{:, end};
testingData=readtable("ClassificationTestData2.xlsx")
tTesting=testingData(:,1:2);
ttestResponse=testingData{:,end};
T=readtable('ClassificationTestData3.xlsx')
[a,b,c]=xlsread('ClassificationTestData3');
save ClassificationTestData3 c

2 Comments

What model did you use? Fine Tree? Did you export trainedModel to trainedModel.mat with the Export button and use load() to read it back in and then use predict on your test data? Please attach trainedModel.mat with the paperclip icon.
@Image AnalystYes the fine tree, I saved the trained model with the code u send me
save('trainedModel69.mat', 'trainedModel69')
and then i loaded with load('trainedModel69.mat')
Am I right?

Sign in to comment.

 Accepted Answer

Cris LaPierre
Cris LaPierre on 17 Jan 2022
Edited: Cris LaPierre on 17 Jan 2022
I was able to train using trainingData and test using testingData in R2021a without getting any errors.
Can you provide more details on what your validation settings were? What did you select for predictors and response?
I selected the table trainingData,. The variables were already correctly selected for predictors and response.. I used the default validation
For test data, I selected testingData. The variables were already correctly selected for predictors and response.

4 Comments

Wow, Yes I did it, but Am i suppose to save and load the trained model before testing?
I was able to reproduce your error, but doing something that doesn't make sense.
You load ClassificatoiTestData3 using [a,b,c]=xlsread('ClassificationTestData3');
The app lets me select a as my Test Input, and assigns ttestResponse as the response data. However, ttestResponse is from ClassificationTestData2. TestData3 actually has no response data in it, so it is not for training or testing, but for using as input to the trained and exported model.
For training and testing, just use the tables for Data2 and testData2. Tables are valid inputs to the Classification Learner App. You do not need to extract anything.
% TRAINING
trainingData=readtable("ClassificationData2.xlsx")
% TESTING
testingData=readtable("ClassificationTestData2.xlsx")
In R2021a, the Classification Learner App lets you import your testing data into the app. You can therefore test without having to export your trained model first.
You do still need to export your trained and tested model in order to make new predictions (data where you do not know the reponse). See this page for how to export and use your trained model to make new predictions.
Assuming I exported my model to a structure named trainedModel, here is how I would make new predictions using the data in ClassificationTestData3 (which is not test data btw).
load pwModel % ignore. This line is for loading the attached trained model
% PREDICT
newData=readtable("ClassificationTestData3.xlsx");
pCluster = trainedModel.predictFcn(newData);
gscatter(newData.Power,newData.WingSpeed,pCluster)
Yes, this is the best answer I want to. Thank youuu

Sign in to comment.

More Answers (1)

In code you can do this:
% Load saved model.
s = load('trainedModel69.mat')
trainedModel69 = s.trainedModel69
% Read in test table with columns for power and WingSpeed.
tPredictors = readtable('ClassificationTestData3.xlsx')
% Get estimated output values based on these input values.
predictedValues = trainedModel69.predictFcn(tPredictors)

Asked:

on 17 Jan 2022

Edited:

on 17 Jan 2022

Community Treasure Hunt

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

Start Hunting!