I have a generator object obtained by sklearn http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html
df_fit = clf.fit(df_training, df_label.values.ravel())
generator=clf.staged_decision_function(df_training)
However, I wish to persist the Generator object in generator variable in some file type so I can retrieve them by reading the file back and save into a variable. I had tried using pickle with
pickle.dumps(generator)
The approach failed and from Google I learnt that we cannot serialize generator object in pickle. I am trying to save it in txt but I don't think it is the proper way to do. Any idea?