Return the size of topics (descending order). Arguments: topic: A specific topic for which you want the frequency Returns: Either the frequency of a single topic or dataframe with the frequencies of all topics Examples: To extrac
(self, topic: int | None = None)
| 1701 | return info.reset_index(drop=True) |
| 1702 | |
| 1703 | def get_topic_freq(self, topic: int | None = None) -> Union[pd.DataFrame, int]: |
| 1704 | """Return the size of topics (descending order). |
| 1705 | |
| 1706 | Arguments: |
| 1707 | topic: A specific topic for which you want the frequency |
| 1708 | |
| 1709 | Returns: |
| 1710 | Either the frequency of a single topic or dataframe with |
| 1711 | the frequencies of all topics |
| 1712 | |
| 1713 | Examples: |
| 1714 | To extract the frequency of all topics: |
| 1715 | |
| 1716 | ```python |
| 1717 | frequency = topic_model.get_topic_freq() |
| 1718 | ``` |
| 1719 | |
| 1720 | To get the frequency of a single topic: |
| 1721 | |
| 1722 | ```python |
| 1723 | frequency = topic_model.get_topic_freq(12) |
| 1724 | ``` |
| 1725 | """ |
| 1726 | check_is_fitted(self) |
| 1727 | if isinstance(topic, int): |
| 1728 | return self.topic_sizes_[topic] |
| 1729 | else: |
| 1730 | return pd.DataFrame(self.topic_sizes_.items(), columns=["Topic", "Count"]).sort_values( |
| 1731 | "Count", ascending=False |
| 1732 | ) |
| 1733 | |
| 1734 | def get_document_info( |
| 1735 | self, |