我有以下交叉验证线性SVM的实现。我想知道哪个输出变量代表特征权重,因此特征的相关性?在存储训练分类器参数的“cl”变量中,我找到变量“W”和“alpha” - 据我所知,alpha表示分类器系数 - 因此alpha是反映每个分类器重要性的变量特征?在我的情况下,“W”似乎对于每个条目几乎为零,而alpha在0和1之间,通常等于1.
%% SVM-Classification
nrFolds = 10; %number of folds of crossvalidation, 10 is standard
kernel = 'linear'; % 'linear', 'rbf' or 'polynomial'
C = 1; % C is the 'boxconstraint' parameter. Small C = Allow for more missclassif.
solver = 'L1QP';
cvFolds = crossvalind('Kfold', labels, nrFolds);
for i = 1:nrFolds % iteratre through each fold
testIdx = (cvFolds == i); % indices of test instances
trainIdx = ~testIdx; % indices training instances
% train the SVM
cl = fitcsvm(features(trainIdx,:), labels(trainIdx),'KernelFunction',kernel,'Standardize',true,...
'BoxConstraint',C,'ClassNames',[0,1],'Solver',solver);
[label,scores] = predict(cl, features(testIdx,:));
eq = sum(label==labels(testIdx));
accuracy(i) = eq/numel(labels(testIdx));
end
crossValAcc = mean(accuracy)