www.gusucode.com > stats 源码程序 matlab案例代码 > stats/SelectSVMClassifierFeaturesUsingResubEdgeExample.m
%% Select SVM Classifier Features by Comparing In-Sample Edges % The classifier edge measures the average of the classifier margins. One % way to perform feature selection is to compare training sample edges from % multiple models. Based solely on this criterion, the classifier with the % highest edge is the best classifier. %% % Load the |ionosphere| data set. Define two data sets: % % * |fullX| contains all predictors (except the removed column of 0s). % * |partX| contains the last 20 predictors. % % Copyright 2015 The MathWorks, Inc. load ionosphere fullX = X; partX = X(:,end-20:end); %% % Train SVM classifiers for each predictor set. FullSVMModel = fitcsvm(fullX,Y); PartSVMModel = fitcsvm(partX,Y); %% % Estimate the training sample edge for each classifier. fullEdge = resubEdge(FullSVMModel) partEdge = resubEdge(PartSVMModel) %% % The edge for the classifier trained on the complete data set is greater, % suggesting that the classifier trained using all of the predictors has a % better in-sample fit.