Hyperplane in SVM classifier

2019-03-01 15:34发布

I want to get a formula for hyperplane in SVM classifier,

so I can calculate the probability of true classification for each sample according to distance from hyperplane.

For simplicity imagine MATLAB's own example,

load fisheriris
xdata = meas(51:end,3:4);
group = species(51:end);
svmStruct = svmtrain(xdata,group,'showplot',true);

Which gives,

enter image description here

Where the hyperplane is a line and I want the formula for that.

The hyperplane can also have a messy shape!

What can I do? maybe there are other ways.

Thanks for any help.

1条回答
Lonely孤独者°
2楼-- · 2019-03-01 16:09

SVM-based classifier contains Support Vectors

to read it from svmStruct a bit more easily, use svmtrain call with "AUTOSCALE", false:

svmStruct.SupportVectors

svmStruct = 

          SupportVectors: [3x2 double]
                   Alpha: [3x1 double]
                    Bias: -23.1428
          KernelFunction: @linear_kernel
      KernelFunctionArgs: {}
              GroupNames: [150x1 logical]
    SupportVectorIndices: [3x1 double]
               ScaleData: []
           FigureHandles: {[170.0012] [171.0052 172.0018] [225.0018]}


ans =

    5.5000 3.5000
    4.5000 2.3000
    4.9000 2.5000

or

>> data( svmStruct.SupportVectorIndices,: )

ans =

    5.5000 3.5000
    4.5000 2.3000
    4.9000 2.5000

If you use the default 'autoscale' option, then you will need to unwind the scaling using something rather ugly like this:

 (    data( svmStruct.SupportVectorIndices( 1 ),: )
    + svmStruct.ScaleData.shift
  ).* svmStruct.ScaleData.scaleFactor

( >>> https://www.mathworks.com/matlabcentral/newsreader/view_thread/249055 )


For construction of a separating Hyperplane from SVM-classifier internal data, you may be interested in >>> http://scikit-learn.org/stable/auto_examples/svm/plot_separating_hyperplane.html

enter image description here Parameters for to plot the maximum margin separating hyperplane within a two-class separable dataset using a Support Vector Machines classifier with linear kernel

查看更多
登录 后发表回答