【发布时间】:2012-02-14 19:02:43
【问题描述】:
我正在使用 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);
有没有更好的方法来确定分类器的准确性,或者我应该做哪些更正来改进上面的代码?
【问题讨论】:
-
那么,矢量
Class是什么样的?是非负整数的 NaN 向量吗? -
类是一个 117 x1 矩阵。值是 1 或 -1... 1 表示正数,-1 表示负数
-
您可以尝试将
-1条目设置为0看看是否有任何效果? -
您的意思是将我的 trainlabel 和 testlabel 值更改为 0 或 1?