ddangelov / Top2Vec

Top2Vec learns jointly embedded topic, document and word vectors.
BSD 3-Clause "New" or "Revised" License
2.95k stars 374 forks source link

How to get the topc size and topic number of reduced model #327

Open josepius-clemson opened 1 year ago

josepius-clemson commented 1 year ago

Could you please tell me how to get the topic size and topic number of the reduced hierarchical model?

MuntahaShams commented 1 year ago

have you found the solution?

yananma1029 commented 1 year ago

Could you please tell me how to get the topic size and topic number of the reduced hierarchical model?

Hi did you manage to reduce the number of topics?

Vela-zz commented 1 year ago

` def get_num_topics(self, reduced=False): """ Get number of topics. This is the number of topics Top2Vec has found in the data by default. If reduced is True, the number of reduced topics is returned. Parameters

    reduced: bool (Optional, default False)
        The number of original topics will be returned by default. If True
        will return the number of reduced topics, if hierarchical topic
        reduction has been performed.
    Returns
    -------
    num_topics: int
    """

    if reduced:
        self._validate_hierarchical_reduction()
        return len(self.topic_vectors_reduced)
    else:
        return len(self.topic_vectors)`

i think just set reduced=True, and you can get topics after reduced and topic size is in same way. This Module store raw model and raw topics seperately.