Output libsvm .model files
(too old to reply)
Leigh Smith
2016-05-10 23:44:30 UTC
I have trained & validated a SVM using the scikit-learn SVC (RBF) class without problems, but my final deployment of the classifier is to be in a body of C++ code using libsvm only, no Python, and this is an existing system reading the libsvm .model sparse format text file. To save retraining using the libsvm command line tools, I'm considering implementing a SVC method to write the equivalent libsvm .model file from the SVC attributes such as support_vectors_ etc. I wanted to ask the experts about the feasibility, particularly if there are pitfalls I'm not aware of? That does assume that the support vectors would themselves be compatible, given libsvm as the common code base?

Leigh M. Smith
Olivier Grisel
2016-05-11 07:54:32 UTC
I have not looked into it my-self but I don't see any particular
road-block that would prevent you to do that.

Be careful that you will have to also re-implement the feature
preprocessing (e.g. scaling) in your C++ code base to get the correct
Olivier Grisel
2016-05-11 07:57:27 UTC
scikit-learn versions of libsvm has been extended to be able to work
with training data represented as dense arrays (directly addressing
the memory of a floating point numpy array) in addition to the native
sparse data reprenentation of the original libsvm. So presumably you
might have to convert your support vectors from one representation to
the other but that should not be very complicated.

Continue reading on narkive: