【问题标题】:MATLAB fitcSVM weight vectorMATLAB fitcSVM 权重向量
【发布时间】:2018-12-15 04:41:37
【问题描述】:

我正在 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 中看到“向量 β 包含定义与超平面正交向量的系数”——因此 cl.beta 代表分类权重吗? p>

【问题讨论】:

    标签: matlab machine-learning classification svm pattern-recognition


    【解决方案1】:

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

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

    如你所知,这个等式显示以下关系:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-24
      • 1970-01-01
      • 2022-07-02
      • 1970-01-01
      • 2014-04-15
      • 2019-08-27
      相关资源
      最近更新 更多