Failed to Call Classification Learner's Testing Function
7 次查看(过去 30 天)
显示 更早的评论
I was using a Matlab R2015b's Classification Learner Toolbox. I was successful in importing file data and export it into an Export Model, and i got a structure named trainedClassifier.
Import process #1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153421/image.jpeg)
Import process #2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153422/image.jpeg)
Training process with PCA implemented & Multi Class SVM (One vs All validation)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153423/image.jpeg)
trainedClassifier variable generated from ToolBox
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153424/image.jpeg)
fetureVector variable which used for testing
yfit = trainedClassifier.predictFcn(featureVector)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153425/image.jpeg)
>> yfit = trainedClassifier.predictFcn(featureVector)
Then i got an error output as a follows :
Function 'subsindex' is not defined for values of class 'cell'.
Error in mlearnapp.internal.model.DatasetSpecification>@(t)t(:,predictorNames) (line 135)
extractPredictorsFromTableFcn = @(t) t(:,predictorNames);
Error in mlearnapp.internal.model.DatasetSpecification>@(x)extractPredictorsFromTableFcn(splitMatricesInTableFcn(convertMatrixToTableFcn(x)))
(line 136)
extractPredictorsFcn = @(x) extractPredictorsFromTableFcn(splitMatricesInTableFcn(convertMatrixToTableFcn(x)));
Error in mlearnapp.internal.model.DatasetSpecification>@(x)exportableClassifier.predictFcn(extractPredictorsFcn(x)) (line 137)
exportableClassifier.predictFcn = @(x) exportableClassifier.predictFcn(extractPredictorsFcn(x));
What is the problem and solutions?
Thanks in advance.
11 个评论
PAVITHRA S
2020-3-2
i tried the above code to test my trained network(classiification learner app). i am unable to execute the code
VarNames = arrayfun(@(N) sprintf('VarName%d',N), 1:512, 'Uniform', 0);
FV_table = array2table( featureVector, 'VariableNames', VarNames);
yfit = trainedClassifier.predictFcn(FV_table)
can u suggest me a solution to test.
Mrutyunjaya Hiremath
2020-4-12
'testingData.xlsx' contains only 512 colums feature vector of tesing data or matrix of N X 512.
testingData = xlsread('testingData.xlsx');
yFit = trainedClassifier.predictFcn(testingData);
采纳的回答
Walter Roberson
2016-4-9
You have
yfit = trainedClassifier.predictFcn(featureVector)
and my reading just now suggest that perhaps needs to be
yfit = predict(trainedClassifier, featureVector)
The error message indicates that something is trying to be indexed using a cell array as a subscript, which is a valid indexing method for tables but not an indexing method for a double array.
19 个评论
更多回答(2 个)
Jingwei Too
2020-7-23
you may have a look on this toolbox https://www.mathworks.com/matlabcentral/fileexchange/71461-simple-machine-learning-algorithms-for-classification?s_tid=prof_contriblnk
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!