Orange Forum • View topic - How to test on Unseen Data and View Predictions

How to test on Unseen Data and View Predictions

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

How to test on Unseen Data and View Predictions

Postby re832003 » Thu Mar 07, 2013 2:57

Hi,


I'm using SVM. Is there a way to save the trained model and use it later on unseen test sets?

Thanks

Re: How to test on Unseen Data and View Predictions

Postby Ales » Thu Mar 07, 2013 10:47

You can use standard python pickle/cPickle serialization.

Re: How to test on Unseen Data and View Predictions

Postby re832003 » Thu Mar 07, 2013 10:53

Many thanks for the quick reply. I've used the code from a previous reply of yours.

I have one more questions, please. How can I modify this code to print not only the predictions but the prediction and the instance itself so I can see which instances perform poorly/well and write an error analysis.

Many Thanks,

Rania

Code: Select all
import Orange, cPickle

data = Orange.data.Table("train.tab")
classifier = Orange.classification.svm.LinearSVMLearner(data)
cPickle.dump(classifier, open("linear_svm.pck", "wb"))


# later:


classifier = cPickle.load(open('linear_svm.pck'))
data_validation = Orange.data.Table('test.tab')
print 'predictions:'
for e in data_validation:
    print classifier(e)



Re: How to test on Unseen Data and View Predictions

Postby Ales » Thu Mar 07, 2013 10:58

Code: Select all
for e in data_validation:
    print e, classifier(e)


Return to Questions & Support



cron