Feature Selection with SVM

5 visualizaciones (últimos 30 días)
MiauMiau
MiauMiau el 30 de Sept. de 2015
Hi
I want to follow the same approach as suggested here, with t-testing and forward feature selection:
I have the following code, though my last line throws an error - how can program this approach with SVM? I do not see a straightforward way using crossval in combination with SVM and cvpartition - or am I wrong?
clear
load std_feature; %data to classify, 84x19900 double matrix
load class; % labels, 84x1 double matrix
holdoutCVP = cvpartition(class,'holdout',30); % perform t-test on 54 training samples
dataTrain = std_feature(holdoutCVP.training,:); %trainings-data
classTrain = class(holdoutCVP.training); %trainings-labels
dataTrainG1 = dataTrain(classTrain==1,:);
dataTrainG2 = dataTrain(classTrain==0,:);
[h,p,ci,stat] = ttest2(dataTrainG1,dataTrainG2,'Vartype','unequal');
ecdf(p);
xlabel('P value');
ylabel('CDF value');
[~,featureIdxSortbyP] = sort(p,2); % sort the features
testMCE = zeros(1,14);
nfs = 5:5:70; % forward feature selection with SVM
for i = 1:14
fs = featureIdxSortbyP(1:nfs(i));
SVMModel = fitcsvm(std_feature(:,fs),class);
% following line does not work for SVMModel:
testMCE(i) = crossval(SVMModel,'partition',holdoutCVP)...
/holdoutCVP.TestSize;
end

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by