相关代码 |
|
load iris.dat data = iris; k = 1; featureNum = size(iris, 2)-1; feature = iris(:, 1:end-1); output = iris(:, end); for i=1:featureNum, allCombination = combinat(1:featureNum, i); for j=1:size(allCombination,1); thisData = [data(:, allCombination(j,:)) output]; looError = looknn(thisData, k); fprintf('Selected input: '); for k=1:size(allCombination,2), fprintf('%g ', allCombination(j,k)); end fprintf(' ===> Leave-one-out error = %g\n', looError); end end