⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 knndemo.m

📁 source code for pattern classification k nearest neighbor source code
💻 M
字号:
clear all
load iris_tra; load iris_tes; % load training and testing file
% feature dimension = 4, target dimension = 3
Pr=iris_tra(:,1:4); Tr=iris_tra(:,5:7);
Pt=iris_tes(:,1:4); Tt=iris_tes(:,5:7);
disp('using Iris data set, feature dimension = 4, 3 classes');

for k=1:15,
   [Cmat,C_rate(k)]=knn(Pr,Tr,Pt,Tt,k);
   disp([int2str(k) '-nearest neighbor classifier, confusion matrix = '])
   Cmat
end

figure(1),clf
stem([1:15],100-C_rate),title('Classification error rate vs. k')
xlabel('k -nearest neighbors')
ylabel('% classification error')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -