viisar / brew

⛔️ DEPRECATED brew: Python Ensemble Learning API
MIT License
301 stars 70 forks source link

How to save and restore model #33

Open Shuang0420 opened 6 years ago

Shuang0420 commented 6 years ago

I tried to save and load model as I usually do when using sklearn model, but the evaluation result of model is apparently not the same. Anything wrong with my code?

save model

tree = DecisionTreeClassifier(max_depth=1, min_samples_leaf=1)
bag = Bagging(base_classifier=tree, n_classifiers=10)
bag.fit(text, labels)
with open(bag_path, "wb") as f:
  pickle.dump(bag, f)

load model

with open(self.bag_path, "rb") as f:
  self.bag = pickle.load(f)