I'm looking for a SVM implementation with support for non-linear kernels and one-vs-rest scenario, to perform a multi-label classification. Preferably, written in Python, or that I can call from Python with wrappers.
I was looking into sklearn, and there are two implementations to use SVM for classification:
sklearn.svm.LinearSVC - supports multi-label classification with a one-vs.-rest scenario, but it's based on liblinear, and therefore only supports linear kernels.
sklearn.svm.SVC - based on libsvm, supports non-linear kernels, but multi-label classification is done under a one-vs.-one reduction, it trains K (K − 1) / 2 binary classifiers for a K-way multiclass problem.
More info also here: http://scikit-learn.org/stable/modules/multiclass.html
Does anyone knows any other SVM implementations directly supporting multi-label classification and non-linear kernels ?
One possible solution could also be to adapt the code based on sklearn.svm.SVC, to perform One-vs-Rest, was this already attempted before?
Binary Relevance problem transformation method uses one-vs-rest approach for doing multi-label classification. One could easily implement SVM with non-linear kernels using scikit-multilearn library. The following is the sample python code to do the same, where each row of train_y is a one-hot vector representing multiple labels (For instance, [0,0,1,0,1,0])
from skmultilearn.problem_transform.br import BinaryRelevance
from sklearn.svm import SVC
# Non-linear kernel
svm = SVC(kernel='rbf')
cls = BinaryRelevance(classifier=svm)
cls.fit(train_x, train_y)
predictions = cls.predict(test_x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With