自学内容网 自学内容网

matlab2022a 函数或变量 ‘knnclassify‘ 无法识别(已解决)

之前是matlab2016b,写的这个KNN,跑的没什么问题,中午重装matlab换成2019b了,同样的程序上午还在用,下午就不行了。

%数据集划分

flag=fix(0.8*n);

x_train=data(idx(1:flag),:);

y_train=label(idx(1:flag),:);

x_test=data(idx(flag+1:end),:);

y_test=label(idx(flag+1:end),:);

%knn分类

class = knnclassify(x_test, x_train, y_train,2);%k取2

acc=sum(class==y_test)/size(class,1);

plot(class,'k*');

hold on;

plot(y_test,'ro');

legend('预测值','实际值')


原文地址:https://blog.csdn.net/Vertira/article/details/142470291

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!