Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I am using SVM for document categorization. For that I have training sets i.e. set of training vector with their category. For example I have following sample data(assumption):

   -1 1:1 2:1
   +1 2:1 4:1
   -1 3:1 5:1
   +1 1:1 6:1

Can any one say:

1) How to plot the data points in vector space(Sample diagram for the given test data will help me best)?

2) How to calculatehyperplane using the given sample?.

3) How to classify the new document using hyperlane for following data?

       2:1 4:1

4)Whether the kernel function are used for generating hypherlane efficiently?


My sample data:
-1 3:1 11:1 14:1 19:1 39:1 42:1 55:1 64:1 67:1 73:1 75:1 76:1 80:1 83:1 
-1 3:1 6:1 17:1 27:1 35:1 40:1 57:1 63:1 69:1 73:1 74:1 76:1 81:1 103:1 
-1 4:1 6:1 15:1 21:1 35:1 40:1 57:1 63:1 67:1 73:1 74:1 77:1 80:1 83:1 
-1 5:1 6:1 15:1 22:1 36:1 41:1 47:1 66:1 67:1 72:1 74:1 76:1 80:1 83:1 
-1 2:1 6:1 16:1 22:1 36:1 40:1 54:1 63:1 67:1 73:1 75:1 76:1 80:1 83:1 
-1 2:1 6:1 14:1 20:1 37:1 41:1 47:1 64:1 67:1 73:1 74:1 76:1 82:1 83:1 
-1 1:1 6:1 14:1 22:1 36:1 42:1 49:1 64:1 67:1 72:1 74:1 77:1 80:1 83:1 
-1 1:1 6:1 17:1 19:1 39:1 42:1 53:1 64:1 67:1 73:1 74:1 76:1 80:1 83:1 
-1 2:1 6:1 18:1 20:1 37:1 42:1 48:1 64:1 71:1 73:1 74:1 76:1 81:1 83:1 
+1 5:1 11:1 15:1 32:1 39:1 40:1 52:1 63:1 67:1 73:1 74:1 76:1 78:1 83:1 
-1 5:1 16:1 30:1 35:1 41:1 64:1 67:1 73:1 74:1 76:1 80:1 83:1 
-1 5:1 6:1 15:1 20:1 37:1 40:1 50:1 63:1 67:1 73:1 75:1 76:1 80:1 83:1 
-1 5:1 7:1 16:1 29:1 39:1 40:1 48:1 63:1 67:1 73:1 74:1 76:1 78:1 83:1 
-1 1:1 11:1 18:1 20:1 37:1 42:1 59:1 62:1 71:1 72:1 74:1 76:1 80:1 83:1 
+1 5:1 18:1 19:1 39:1 40:1 63:1 67:1 73:1 74:1 76:1 80:1 83:1 


My Sample model file content:
1.0 3:1.0 11:1.0 14:1.0 19:1.0 39:1.0 42:1.0 55:1.0 64:1.0 67:1.0 73:1.0 75:1.0 76:1.0 80:1.0 83:1.0 
1.0 4:1.0 6:1.0 15:1.0 21:1.0 35:1.0 40:1.0 57:1.0 63:1.0 67:1.0 73:1.0 74:1.0 77:1.0 80:1.0 83:1.0 
1.0 2:1.0 6:1.0 16:1.0 22:1.0 36:1.0 40:1.0 54:1.0 63:1.0 67:1.0 73:1.0 75:1.0 76:1.0 80:1.0 83:1.0 
1.0 5:1.0 6:1.0 15:1.0 20:1.0 37:1.0 40:1.0 50:1.0 63:1.0 67:1.0 73:1.0 75:1.0 76:1.0 80:1.0 83:1.0 
1.0 5:1.0 7:1.0 16:1.0 29:1.0 39:1.0 40:1.0 48:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 78:1.0 83:1.0 
0.47854266714671057 2:1.0 11:1.0 18:1.0 20:1.0 37:1.0 40:1.0 54:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 80:1.0 83:1.0 
1.0 2:1.0 6:1.0 15:1.0 19:1.0 39:1.0 40:1.0 52:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 82:1.0 83:1.0 
1.0 3:1.0 6:1.0 14:1.0 22:1.0 36:1.0 40:1.0 54:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 80:1.0 83:1.0 
1.0 5:1.0 8:1.0 14:1.0 19:1.0 39:1.0 40:1.0 50:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 82:1.0 83:1.0 
0.26128743031116053 3:1.0 7:1.0 18:1.0 22:1.0 36:1.0 40:1.0 50:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 82:1.0 83:1.0 
1.0 5:1.0 15:1.0 22:1.0 36:1.0 40:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 82:1.0 83:1.0 
1.0 1:1.0 15:1.0 21:1.0 35:1.0 45:1.0 62:1.0 68:1.0 72:1.0 74:1.0 77:1.0 80:1.0 93:1.0 
share|improve this question

migrated from stackoverflow.com Aug 22 '12 at 15:28

1 Answer

up vote 2 down vote accepted

Since you have more than two (in this example you have five, to be precise) dimensions, plotting would hardly help. Finding the maximum-margin separating plane is exactly what SVM is for. Unless you intend to implement it yourself, I suggest that you run LIBSVM on your data and read the resulting model file, which will contain the support vector coordinates. I'm not sure how to get the separating hyperplane out of that, but even if you do, it'll only be a hyperplane in the kernel space, not in the one where your samples are. If you just want to do linear classification, it may be better to use LIBLINEAR instead -- it's input format is the same as that of LIBSVM.

The decoding (i.e. predicting the class for a new sample) can be done either by invoking the corresponding binary from the distribution.

share|improve this answer
Hi Qnan.. I have tested LIBSVM with some sample data given in site.. I got model created by LIBSVM trainer. I have updated my question with sample training data and model created.. Can you please highlight which one is hyperplane coordinate? – vignesh kumar rathakumar Aug 21 '12 at 14:52
@vigneshkumarrathakumar see the edit. – Qnan Aug 21 '12 at 15:05
I believe if you have just two classes, then after running LIBSVM will contain a column of weights w that specify the hyperplane. The classification then should be something like comparing the dot product of that vector with a feature vector of a new sample and comparing that to zero. – Qnan Aug 21 '12 at 15:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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