Skip to content

Commit

Permalink
Topic modelling - Reorder methods by relevance
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Nov 3, 2023
1 parent 8e03e0c commit dc41ddf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions orangecontrib/text/widgets/owtopicmodeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def on_done(self, corpus):
if self.model.name == "Latent Dirichlet Allocation":
bound = self.model.model.log_perplexity(infer_ngrams_corpus(corpus))
self.perplexity = "{:.5f}".format(np.exp2(-bound))
else:
self.perplexity = "n/a"
# for small corpora it is slower to use more processes
# there is no good estimation when multiprocessing is helpful, but it is
# definitely not helpful for corpora smaller than 100
Expand Down
14 changes: 6 additions & 8 deletions orangecontrib/text/widgets/tests/test_owtopicmodeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_data(self):
self.assertIsNone(output)

def test_saved_selection(self):
self.widget.method_index = 1
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.wait_until_finished()

Expand Down Expand Up @@ -58,17 +57,16 @@ def test_topic_evaluation(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.wait_until_finished()

# test LSI
self.assertEqual(self.widget.perplexity, "n/a")
self.assertNotEqual(self.widget.coherence, "n/a")

# test LDA, which is the only one with log perplexity
self.assertNotEqual(self.widget.perplexity, "n/a")
self.assertTrue(self.widget.coherence)

# test LSI
self.widget.method_index = 1
self.widget.commit.now()
self.wait_until_finished()

self.assertNotEqual(self.widget.perplexity, "n/a")
self.assertTrue(self.widget.coherence)
self.assertEqual(self.widget.perplexity, "n/a")
self.assertNotEqual(self.widget.coherence, "n/a")

def test_migrate_settings_transform(self):
# 0 used to be LSI in version <2 - it is on index 1 now
Expand Down

0 comments on commit dc41ddf

Please sign in to comment.