What is causing the error from matlab predict function? Also, how to format data to use in classifier validation?
3 次查看(过去 30 天)
显示 更早的评论
Using MATLAB 2015a Classification Learner App, I've trained a Cubic SVM model. I'd like to validate a new data point with this model, but on attempt the following error is produced:
Variables have been created in the base workspace.
To use the exported classifier 'trainedClassifier1' to make predictions on new data, T, use
yfit = predict(trainedClassifier1, T{:,trainedClassifier1.PredictorNames})
If your new data contains any integer variables, then preprocess the data to doubles like this:
X = table2array(varfun(@double, T(:,trainedClassifier1.PredictorNames)));
yfit = predict(trainedClassifier1, X)
>> T = featureMatrix(:,7);
>> yfit = predict(trainedClassifier1, T{:,trainedClassifier1.PredictorNames})
Error using numel
Bad subscripting index.
What is causing this error?
Also, my training data was 4629x8, where the eighth column was the label (response). For the new data, the eighth column has been removed, i.e., 433x7, since the label column should not be needed (or in practice is not known). Is this the correct data format?
0 个评论
回答(2 个)
Brendan Hamm
2015-5-22
Given the error it seems that maybe your data contains values which are not doubles (i.e. integers) which need to first be cast to doubles. The error even suggests to you how to do this. If you provide your code this would make it much easier to figure out what is going on, as otherwise I am guessing based on the error.
2 个评论
MEENU SAINI
2018-5-10
Right ans is here:
https://in.mathworks.com/matlabcentral/answers/289168-using-exported-classifer-model
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!