Question

I'm trying to use scikit-learn AdaBoostClassifier, and i'm trying to serialize the output classifier using cPickle to save it to database or a file, but i got out of memory error, and when i used marshal, it gave me the unmarshable object. So, i'm wondering how i can serialize this learned classifier.

def adboost_classify(X,Y):
   bdt = AdaBoostClassifier(DecisionTreeClassifier(max_depth=10),
                    algorithm="SAMME.R",
                     n_estimators=3000)
   t0 = time()
   bdt.fit(X, Y)
   t1 = time()
   thebytes = cPickle.dumps(bdt)

thank you in advance

No correct solution

OTHER TIPS

This is because you attempt to store the whole representation in memory. Try writing it to a file directly instead:

with open('adaboostpickled.tmp', 'w') as output:
    cPikle.dump(bdt, output)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top