class LDATests(unittest.TestCase, BaseTests): def setUp(self): self.corpus = Corpus.from_file('deerwester') self.model = LdaWrapper(num_topics=5) def test_too_large_id(self): self.model.fit(self.corpus) with self.assertRaises(ValueError): self.model.get_topics_table_by_id(6) def test_fit_transform(self): corpus = super().test_fit_transform() self.assertEqual(len(corpus.domain.attributes), 5) self.assertEqual(corpus.X.shape, (len(self.corpus), 5))
def setUp(self): self.corpus = Corpus.from_file('deerwester') self.model = LdaWrapper(num_topics=5)
self.on_params_change() def set_visual_settings(self, key: KeyType, value: ValueType): self.graph.parameter_setter.set_parameter(key, value) self.visual_settings[key] = value def clear(self): self.Error.clear() self.graph.clear_all() self.data = None self.topic_list = [] self.term_topic_matrix = None self.term_frequency = None self.num_tokens = None def send_report(self): self.report_items(( ("Relevance", self.relevance), ("Shown topic", self.topic_list[self.selected_topic]), )) self.report_plot() if __name__ == "__main__": corpus = Corpus.from_file("deerwester") lda = LdaWrapper(num_topics=5) lda.fit_transform(corpus) topics = lda.get_all_topics_table() WidgetPreview(OWLDAvis).run(topics)