Saturday 15 March 2014

python - scikit-learn, linearsvc - how to get support vectors from the trained SVM? -



python - scikit-learn, linearsvc - how to get support vectors from the trained SVM? -

i using linearsvc scikit-learn library , wonder if possible somehow pull out vectors model uses after training create predictions. tried google time without luck. knows?

unfortunately there seems no way that. linearsvc calls liblinear (see relevant code) doesn't retrieve vectors, coefficients , intercept.

one alternative utilize svc 'linear' kernel (libsvm instead of liblinear based), poly, dbf , sigmoid kernel back upwards option:

from sklearn import svm x = [[0, 0], [1, 1]] y = [0, 1] clf = svm.svc(kernel='linear') clf.fit(x, y) print clf.support_vectors_

output:

[[ 0. 0.] [ 1. 1.]]

liblinear scales improve big number of samples, otherwise equivalent.

python machine-learning scikit-learn

No comments:

Post a Comment