I have trained a LDA model using below command, need to understand how to save it.
lda_model = LatentDirichletAllocation(n_components=25, random_state=100)
I have tried the below method, but it is saying
AttributeError: 'LatentDirichletAllocation' object has no attribute 'save'
lda_model.save("xyz.model")
It took 16 hours to train the model. Re-creating it will be very time consuming. Any advise will be really appreciated!
Models are serializable in scikit-learn, thus you can save it with:
import pickle
pickle.dump(lda_model, 'lda_model.pk')
# then reload it with
lda_model = pickle.load('lda_model.pk')
Note that, according to the doc, you may want to prefer joblib when model contains large estimators
import joblib
joblib.dump(lda_model, 'lda_model.jl')
# then reload it with
lda_model = joblib.load('lda_model.jl')
As mentioned by Michael Silverstein, it is documented here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With