我正在使用 KNN 分类器,我发现 knnclassify 在 MATLAB 中为我进行了分类。
代码:
Class = knnclassify(TestVec,TrainVec, TrainLabel);
我现在面临的问题,knnclassify 只是对点进行分类并给它们一个值,但我想找到这种分类的准确性。
我试过这样的事情:
Class = knnclassify(TestVec,TrainVec, TrainLabel);
cp = classperf(TestLabel,Class);
cp.CorrectRate
它给了我这个错误:
??? Error using ==> classperf at 149
When the class labels of the CP object are numeric, the output
of the classifier must be all non-negative integers or NaN's.
Error in ==> KNN at 3
cp = classperf(TestLabel,Class);
有没有更好的方法来找到分类器的准确性,或者我应该做哪些更正来改进上面的代码?