Question

I'm using LinearSVM from SciKit library in python to classify text data, and it works perfectly. My question is that is there a way to find the support vectors of my classifier model? I think the support vectors for my data would be a list of words!

I need this because I want to find a distinguishing feature of the classifier for different text data. (How different text data are distinct)

Thanks in advance.

Was it helpful?

Solution

For the SVM case in scikit-learn you should be able to access the support vectors in the following way:

>>> # get support vectors
>>> clf.support_vectors_
array([[ 0.,  0.],
       [ 1.,  1.]])
>>> # get indices of support vectors
>>> clf.support_ 
array([0, 1]...)
>>> # get number of support vectors for each class
>>> clf.n_support_ 
array([1, 1]...)

[Source: http://scikit-learn.org/stable/modules/svm.html ]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top