Feature Selection with SVM
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Gaussian Process Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!