Feature Selection with SVM
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gaussian Process Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!