MATLAB fitcSVM 权重矢量



我正在使用 MATLAB 中的 fitcsvm 函数训练线性 SVM 分类器:

cvFolds = crossvalind('Kfold', labels, nrFolds);
for i = 1:nrFolds                       % iterate through each fold
testIdx = (cvFolds == i);            % indices of test instances
trainIdx = ~testIdx;                 % indices training instances
cl = fitcsvm(features(trainIdx,:), 
labels(trainIdx),'KernelFunction',kernel,'Standardize',true,...
'BoxConstraint',C,'ClassNames',[0,1], 'Solver', solver);
[labelPred,scores] =  predict(cl, features(testIdx,:));
eq = sum(labelPred==labels(testIdx));
accuracy(i) = eq/numel(labels(testIdx));
end

从这部分代码中可以看出,经过训练的 SVM 模型存储在 cl 中。 在 cl 中检查模型参数 我没有看到哪些参数对应于分类器权重 - 即。 线性分类器的参数,它反映了每个特征的重要性。哪个参数表示分类权重?我在 MATLAB 文档中看到"向量β包含定义超平面正交向量的系数"——因此 cl.beta 是否表示分类权重?

正如您在本文档中看到的,fitcsvmhyperplane的方程为

f(x)=x′β+b=0

如您所知,此等式显示了以下关系:

f(x)=w*x+b=0 or f(x)=x*w+b=0

因此,β等于w(权重(。

最新更新