Feature Selection with SVM
Afficher commentaires plus anciens
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
Réponses (0)
Catégories
En savoir plus sur Gaussian Process Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!