Orange Forum • View topic - pickle load

pickle load

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

pickle load

Postby jon » Tue Jan 12, 2010 15:52

occassionally after training a classifier and pickling it.

when I try and pickle.load the classifier I get a segmentation fault.

Not sure what is going wrong,,

has anyone come across this before

below is the code for generating the classifier.

Im not sure what Im doing wrong,..


Code: Select all
from RankTargets import *
import os
import orange, orngSVM, orngTest, orngStat,orngTree, orngEnsemble, random
import cPickle as pickle
from numpy import  *

from TeaCoffee import *


rf = orngEnsemble.RandomForestLearner(trees=100, name="forest_gen_cath")

"""first grid no deg for C-SVM gave
gamma=2,C=0.125
changed this to C: 2048 gamma: 0.125 on a later smaller search
with deg optimal was gamma=8,C=32,
nu-svm Optimal set of parameters:  nu: 0.4 gamma: 0.03125
"""

jroot="/home/owner/jons/jons/jon_go/jroot/" 
rt = RankCcTargets(jroot=jroot)
tt=TtUtil(jroot,rt)

#fname = "gen_%s_sub_2"
fname = "gen_%s"
#FOR DEG
svm = orngSVM.SVMLearner(name = "svm_gen", gamma=8,C=32, svm_type=orange.SVMLearner.C_SVC,probability=False, normalization = True)
#NO DEG
#svm = orngSVM.SVMLearner(name = "svm_gen", gamma=0.125,C=2048, svm_type=orange.SVMLearner.C_SVC,probability=False, normalization = True)
learner = svm


learner.name = 'svm'

data = orange.ExampleTable(os.path.join(jroot,'CC_PROJECT_DATA/ORNG_DATA/',(fname % 'train') + ".tab" ))
test = orange.ExampleTable(os.path.join(jroot,'CC_PROJECT_DATA/ORNG_DATA/',(fname % 'test') + ".tab" ))
print "LEARNING"
claf=learner(data)   
print "LEARNT"
pickle.dump(claf,open(os.path.join(jroot,'CC_PROJECT_DATA/classifiers/', (fname  % learner.name) + ".pkl"),'w'),protocol = 2)

Postby jon » Tue Jan 12, 2010 18:39

Further checking reveals the component that refuses to unpickle
is claf.classifier.nSV

Postby jon » Tue Jan 12, 2010 19:06

Actually checking again ,
I can pickle.dump and pickle.load all of the claf.classifiers attributes
its just the classifier as a whole for some reason that crashes on pickle.load


Return to Questions & Support