Data visualization with pyLDAvis
In Chapter 11, LDA Modeling, we saved the LDA model and its dictionary for future use. Now we will load the LDA model and the dictionary. The MmCorpus()
function loads the BoW object saved previously in the Matrix Market (MM) exchange format. The MM exchange format is a format for matrices. You also can use pickle
dump and load to handle the BOW data, as I explained in the previous chapter:
from gensim.models import LdaModelfrom gensim.test.utils import datapath from gensim.corpora import Dictionary
Load the LDA model on the BoW data:
path = “/content/gdrive/My Drive/data/gensim”bow_file = datapath(path + “/LDA_bow_151”) lda_bow = LdaModel.load(bow_file)
Load the LDA model on the TF-IDF data:
tfidf_file = datapath(path + “/LDA_tfidf_151”)lda_tfidf = LdaModel.load(tfidf_file)
Load the dictionary:
dict_file = datapath(path + “/gensim_dictionary_AGnews”)model_dict = Dictionary...