Commit fbb9192a authored by Kathryn Elliott's avatar Kathryn Elliott

Use the topics generator for iterating over the topics.

parent b7518407
......@@ -260,17 +260,16 @@ class TopicModel:
max_coherence_model = None
scores = []
# Documentation for these parameters: https://radimrehurek.com/gensim/models/coherencemodel.html
for n in self._models:
coherence_model = CoherenceModel(model = self._models[n], texts = self._corpus, dictionary = self._dictionary, coherence='c_v')
for topic_number, max_topic in self._topics_generator():
coherence_model = self._coherence_models[topic_number]
coherence_score = coherence_model.get_coherence()
scores.append((n, coherence_score))
scores.append((topic_number, coherence_score))
if(max_coherence_model == None or coherence_score > max_coherence_model.get_coherence()):
max_coherence_model = coherence_model
max_n = n
max_model = self._models[n]
max_n = topic_number
max_model = self._models[topic_number]
for (n, score) in scores:
self._logging.info("Coherence for topic {0} = {1}".format(n, score))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment