aziya mehboob
2018-11-15 10:43:41 UTC
i am trying to use gensim sklearn lda api and tried to show topic words but
not getting any result.
from gensim.sklearn_api.ldamodel import LdaTransformer
print("Topic modeling using LDA...")
dictionary = Dictionary(docs)
corpus = [dictionary.doc2bow(text) for text in docs]
model = LdaTransformer(id2word=dictionary, num_topics=n_topics,
iterations=lda_n_iter,random_state=n_random)
model.fit(corpus)
print("\nTopical words:")
print("-" * 20)
topic_word = model.topic_word_
n_top_words = 8
for i, topic_dist in enumerate(topic_word):
topic_words = np.array(vocab)[np.argsort(topic_dist)][:-(n_top_words+1):-1]
print('Topic {}: {}'.format(i, ' '.join(topic_words)))
i received error as:
AttributeError: 'LdaTransformer' object has no attribute 'topic_word_'
not getting any result.
from gensim.sklearn_api.ldamodel import LdaTransformer
print("Topic modeling using LDA...")
dictionary = Dictionary(docs)
corpus = [dictionary.doc2bow(text) for text in docs]
model = LdaTransformer(id2word=dictionary, num_topics=n_topics,
iterations=lda_n_iter,random_state=n_random)
model.fit(corpus)
print("\nTopical words:")
print("-" * 20)
topic_word = model.topic_word_
n_top_words = 8
for i, topic_dist in enumerate(topic_word):
topic_words = np.array(vocab)[np.argsort(topic_dist)][:-(n_top_words+1):-1]
print('Topic {}: {}'.format(i, ' '.join(topic_words)))
i received error as:
AttributeError: 'LdaTransformer' object has no attribute 'topic_word_'
--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.