-1
$\begingroup$

I want to get a equation of hyperplane in SVM classifier using Matlab in the case of linear separable data which is the easiest case. Actually I do not want to use Kernel function. Is there any way to find the equation of hyperplane in matlab?

$\endgroup$
0
$\begingroup$

All you need can be computed from kernel and support vectors. Matlab stores them in svmStruct. Just call the svmStrain function with autscale on false.

% parameters from svmStruct
w1 = dot(svmStruct.Alpha, svmStruct.SupportVectors(:,1));
w2 = dot(svmStruct.Alpha, svmStruct.SupportVectors(:,2));
bias = svmStruct.Bias;

% y = a*x + b
a = -w1/w2;
b = -svmStruct.Bias/w2;

See also:

https://de.mathworks.com/matlabcentral/newsreader/view_thread/276146

https://stackoverflow.com/questions/16146212/how-to-plot-a-hyper-plane-in-3d-for-the-svm-results/19969412#19969412

https://stackoverflow.com/questions/26549714/hyperplane-in-svm-classifier

$\endgroup$
  • $\begingroup$ thank you very much for your help. i was wondering if you introduce me a data set which is linearly separable. $\endgroup$ – pardis Nov 14 '16 at 5:46
  • $\begingroup$ i don't know a public (large) data set that is linearly separable. But there are many simple ones, like the Fisher Iris Data Set. It's included in matlab: load fisheriris gscatter(meas(:,1), meas(:,2), species,'rgb','osd'); xlabel('Sepal length'); ylabel('Sepal width'); N = size(meas,1); $\endgroup$ – hh32 Nov 14 '16 at 7:28
  • $\begingroup$ thank you so much. However i need large data set for my research. $\endgroup$ – pardis Nov 15 '16 at 4:13
  • $\begingroup$ Then i suggest you take a look at kaggle.com. There are a lot of large datasets you can use. $\endgroup$ – hh32 Nov 15 '16 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.