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
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
Parameters for to plot the maximum margin separating hyperplane within a two-class separable dataset using a Support Vector Machines classifier with linear kernel