MATLAB fitcSVM 权重向量

MATLAB fitcSVM weight vector

我正在使用 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 documentation "The vector β contains the coefficients that define an orthogonal vector to the hyperplane" 中看到 - 因此 cl.beta 代表分类权重?

正如你在这个documentation中看到的,fitcsvm中的hyperplane的等式是

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

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

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

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