BERTopic icon indicating copy to clipboard operation
BERTopic copied to clipboard

How to remove topic -1 from visulization

Open fsysean opened this issue 4 years ago • 4 comments

https://maartengr.github.io/BERTopic/getting_started/visualization/visualization.html#visualize-topics, From your examples, there is no topic-1 on visulizataions but my ouput have. Are there any ways to remove topic -1 from visulization? If I want to edit visulizations, are there any ways? Thank you!

fsysean avatar Jun 08 '22 06:06 fsysean

Typically, the visualization function .visualize_topics() should not show the -1 topic if you are using the most recent version of BERTopic, v0.10. Which version of BERTopic are you using? Also, could you share your code for generating the visualization that has the -1 topic?

If I want to edit visulizations, are there any ways?

The visualization functions typically return a Plotly figure (plotly.graph_objs._figure.Figure) that you can edit yourself. You can find the documentation for that here.

MaartenGr avatar Jun 08 '22 09:06 MaartenGr

Typically, the visualization function .visualize_topics() should not show the -1 topic if you are using the most recent version of BERTopic, v0.10. Which version of BERTopic are you using? Also, could you share your code for generating the visualization that has the -1 topic?

If I want to edit visulizations, are there any ways?

The visualization functions typically return a Plotly figure (plotly.graph_objs._figure.Figure) that you can edit yourself. You can find the documentation for that here.

I tried v0.10 but same thing happed. I think I know the reason why. I have less the number of topic -1 than the number of topic 0.

fsysean avatar Jun 08 '22 12:06 fsysean

Hello @fsysean, I encountered the same issue. Instead of specifiying the top_n_topics which should be displayed, I used the parameter topics of the visualization functions and "manually" specified which topics should be used, i.e. topics 0 through n excluding -1. For example, a function call might look like my_topic_model.visualize_barchart(topics=list(range(10))) if I want a barchart for the top 10 topics excluding topic -1. Hope this helps.

aileen-reichelt avatar Jun 08 '22 21:06 aileen-reichelt

my_topic_model.visualize_barchart(topics=list(range(10)))

Thanks! I is very helpful

fsysean avatar Jun 09 '22 00:06 fsysean