📄 ldaknnrloo.m
字号:
function recogRate=ldaKnnrLoo(DS, maxDim, plotOpt)
% ldaKnnrLoo: LDA analysis using KNNR and LOO
% Usage: recogRate=ldaKnnrLoo(DS, maxDim, plotOpt)
% Roger Jang, 20060507
if nargin<1, selfdemo; return; end
[featureNum, dataNum] = size(DS.input);
if nargin<2, maxDim=featureNum; end
if nargin<3, plotOpt=0; end
if isempty(maxDim), maxDim=featureNum; end
if isnan(maxDim), maxDim=featureNum; end
maxDim=min(maxDim, featureNum);
DS2 = lda(DS);
recogRate=[];
for i = 1:maxDim
DS3=DS2; DS3.input=DS2.input(1:i, :);
[recogRate(i), hitIndex] = knnrLoo(DS3);
hitCount=length(hitIndex);
% fprintf('\t\tLOO recog. rate = %d/%d = %g%%\n', hitCount, dataNum, 100*recogRate(i));
end
if plotOpt
plot(1:maxDim, 100*recogRate, 'o-'); grid on
xlabel('No. of projected features based on LDA');
ylabel('LOO recognition rates using KNNR (%)');
end
% ====== Self demo
function selfdemo
DS=prData('wine');
feval(mfilename, DS, [], 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -