tlooknn.m
来自「一个关于数据聚类和模式识别的程序,在生物化学,化学中因该都可以用到.希望对大家有」· M 代码 · 共 15 行
M
15 行
% Using IRIS data to test looknn.m
load iris.dat
input=iris(:, 1:end-1);
sampleNum=size(iris, 1);
distmat = vecdist(input);
distmat(1:(sampleNum+1):sampleNum^2) = inf; % Set diagonal elements to inf
k=1;
[misclassify, index, nearestSampleIndex] = looknn(iris, k, 0);
table=[index, iris(index, end), nearestSampleIndex, iris(nearestSampleIndex, end)]
fprintf('column 1: index of misclassified sample\n');
fprintf('column 2: class of misclassified sample\n');
fprintf('column 3: index of nearest neighbor of the misclassified sample\n');
fprintf('column 4: class of nearest neighbor of the misclassified sample\n');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?