Is there a way to persist instances of a class in memory or file system in Python? Can I do this with shelve
?
The following line is part of this tutorial which takes a long time to execute, and I need to cache it for next program executions.
clf = MultinomialNB().fit(X_train_counts, training_data['targets'])
Type of clf
:
>>> type(clf)
<class 'sklearn.naive_bayes.MultinomialNB'>