% Input selection based on KNNC and LOO clear all; vsdOpt=vsdOptSet; fprintf('Loading DS.mat...\n'); load DS.mat % Load the dataset % ====== Down sample the training data fprintf('Down sample DS with a rate of %d...\n', vsdOpt.downSampleRate); dataSize=size(DS.input, 2); ratio=round(dataSize/vsdOpt.maxDataSize4inputSelect); DS.input=DS.input(:, 1:ratio:end); DS.output=DS.output(:, 1:ratio:end); fprintf('Actual data size for input selection = %d\n', size(DS.input,2)); %DS.input=inputNormalize(DS.input); % Input (feature) normalization plotOpt=1; % Plot the result of input selection classifier='knncLoo'; % Use knncLoo.m for input selection knncPrm.k=1; % Parameters for the classifier fprintf('inputName=%s\n', cell2str(DS.inputName)); % Print the input names switch vsdOpt.inputSelectionMethod case 'sequential' % ====== Sequential forward selection [bestInputIndex, bestRecogRate, allSelectedInput, allRecogRate, elapsedTime]=inputSelectSequential(DS, vsdOpt.selectedInputNum, classifier, knncPrm, plotOpt); case 'exhaustive' % ====== Exhaustive search [bestInputIndex, bestRecogRate, allSelectedInput, allRecogRate, elapsedTime]=inputSelectExhaustive(DS, vsdOpt.selectedInputNum, classifier, knncPrm, plotOpt); otherwise disp('Unknown method!'); end fprintf('Recognition rate = %f\n', bestRecogRate*100); fprintf('bestInputIndex = %s\n', mat2str(bestInputIndex)); fprintf('bestInputIndex = %s\n', cell2str(DS.inputName(bestInputIndex))); [allRecogRate, index]=sort(allRecogRate); allSelectedInput=allSelectedInput(index); figure; inputSelectPlot(allRecogRate*100, allSelectedInput, DS.inputName, mfilename); fprintf('Save the indices of the selected features to bestInputIndex.mat...\n'); save bestInputIndex bestInputIndex