Map topic IDs to their labels. A label is the topic ID, along with the first four words of the topic representation, joined using '_'. Zeroshot topic labels come from self.zeroshot_topic_list rather than the calculated representation. Returns: topic_labels: a dic
(self)
| 327 | |
| 328 | @property |
| 329 | def topic_labels_(self): |
| 330 | """Map topic IDs to their labels. |
| 331 | A label is the topic ID, along with the first four words of the topic representation, joined using '_'. |
| 332 | Zeroshot topic labels come from self.zeroshot_topic_list rather than the calculated representation. |
| 333 | |
| 334 | Returns: |
| 335 | topic_labels: a dict mapping a topic ID (int) to its label (str) |
| 336 | """ |
| 337 | topic_labels = { |
| 338 | key: f"{key}_" + "_".join([word[0] for word in values[:4]]) |
| 339 | for key, values in self.topic_representations_.items() |
| 340 | } |
| 341 | if self._is_zeroshot(): |
| 342 | # Need to correct labels from zero-shot topics |
| 343 | topic_id_to_zeroshot_label = { |
| 344 | topic_id: self.zeroshot_topic_list[zeroshot_topic_idx] |
| 345 | for topic_id, zeroshot_topic_idx in self._topic_id_to_zeroshot_topic_idx.items() |
| 346 | } |
| 347 | topic_labels.update(topic_id_to_zeroshot_label) |
| 348 | return topic_labels |
| 349 | |
| 350 | def fit( |
| 351 | self, |
nothing calls this directly
no test coverage detected