Reputation: 89
I am training a LDA Model using Gensim:
dictionary = corpora.Dictionary(section_2_sentence_df['Tokenized_Sentence'].tolist())
dictionary.filter_extremes(no_below=20, no_above=0.7)
corpus = [dictionary.doc2bow(text) for text in (section_2_sentence_df['Tokenized_Sentence'].tolist())]
num_topics = 15
passes = 200
chunksize = 100
lda_sentence_model = gensim.models.ldamulticore.LdaMulticore(corpus, num_topics=num_topics,
id2word=dictionary,
passes=passes,
chunksize=chunksize,
random_state=100,
workers = 3)
After training i need the topics for further analysis. Unfortunately the show_topics function only returns 10 topics. I expected the defined number of 15 topics. Does anyone know if that is on purpose or an error that can be solved?
print(len(lda_sentence_model.show_topics(formatted=False)))
Upvotes: 0
Views: 2563
Reputation: 54243
According to the gensim documentation for the .show_topics()
method, its default num_topics
parameter value ("Number of topics to be returned") is 10:
If you want it to return more than 10, supply your preferred non-default value for that method's num_topics
parameter. For example:
len(lda_sentence_model.show_topics(formatted=False, num_topics=15))
Upvotes: 1