cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.55k stars 1.64k forks source link

Importing scikit-learn SVM model to LIBSVM #184

Closed Afef00 closed 1 year ago

Afef00 commented 2 years ago

Hello, I have trained my SVM model for MNIST classification in Python using scikit-learn( Grid searchcv). I need to implement the SVM prediction in C language using the model parameters extracted in Python. I was wondering is there any way to import the trained model to LIBSVM ? Is it possible to use the model parameters (from python) in svm-predict of LIBSVM? Regards,

cjlin1 commented 2 years ago

You can check sources of libsvm python interface about the python model structure

On 2022-04-25 20:06, root wrote:

Hello, I have trained my SVM model for MNIST classification in Python using scikit-learn( Grid searchcv). I need to implement the SVM prediction in C language using the model parameters extracted in Python. I was wondering is there any way to import the trained model to LIBSVM ? Is it possible to use the model parameters (from python) in svm-predict of LIBSVM? Regards,

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you are subscribed to this thread.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/184", "url": "https://github.com/cjlin1/libsvm/issues/184", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Links:

[1] https://github.com/cjlin1/libsvm/issues/184 [2] https://github.com/notifications/unsubscribe-auth/ABI3BHVR3F6BLWGLZMS64G3VG2DEXANCNFSM5UILFYGA

rotkiv1205 commented 1 year ago

I'm also curious about this and didn't get the answer? 😄

cjlin1 commented 1 year ago

What's the structure of the output model of GridSearchCV? If this model is different from the one produced by libsvm, then it's not possible to directly call libsvm for prediction. I think the easiest way is that after GridSearch returns the best configureation, re-train the SVM model by libsvm python interface.