Orange Forum • View topic - Way to extract libsvm model file from Orange SVM ?

Way to extract libsvm model file from Orange SVM ?

A place to ask questions about methods in Orange and how they are used and other general support.

Way to extract libsvm model file from Orange SVM ?

Postby JC » Sat Nov 21, 2009 21:17

Hey,

I'm using orange, at the beginning I was having a hard time but now I'm enjoying myself (thanks for your efforts on this library!!). Death to MATLAB!


Anyways, I disgress. I am using the SVM part of orange and I learned on the website that it uses libsvm. It is a good coincidence for me because the C++ part of my project will also use libsvm, I only use Orange for experimentation/information extraction on my different datasets. Is there a way to extract the .model file that libsvm usually produces when training a classifier from Orange?

Thanks!
JC

Postby Ales » Mon Nov 23, 2009 10:30

You can try getting the model from the pickle string:
Code: Select all
s = cPickle.dumps(svmclassifier)
model = s.split("'")[-8]
print model


I didn't test this with libsvm, so take this with a grain of salt.

Postby JC » Tue Nov 24, 2009 15:34

That string's format doesn't look like what libsvm outputs to save it's model../.

I decided to modifiy TSVMClassifier class in cpp code to run the svm_save_model function with a default filename (i.e. 'lastClassifier.model') everytime it's about to destroy itself.

I wanted to add a new function to be able to call it myself but it seems messy and I don't have so much time :) Thanks for trying to help!

Postby Ales » Mon Dec 07, 2009 10:50

I added a getModel method to orange.SVMClassifer that returns a string containing the model file text. You can rebuild orange from source or wait for tomorrows snapshot to use it.

Postby JC » Tue Dec 08, 2009 16:24

Awesome, thanks !


Return to Questions & Support