BERTopic icon indicating copy to clipboard operation
BERTopic copied to clipboard

Can I remove a given topic from my model?

Open luca2849 opened this issue 3 years ago • 2 comments

Hi, I was just wondering if I am able to delete a specific topic from my model, or would I have to reduce it using the existing methods. Thanks

luca2849 avatar Aug 10 '22 09:08 luca2849

It is currently not directly possible to remove a specific topic entirely from the model. You could try to merge it with other topics that are not of interest or indeed use reduction techniques.

In the upcoming v0.12 release of BERTopic, you can use .update_topics to assign specific topics to the -1 class so that it will be ignored in most visualizations. However, it would technically not be deleted.

Out of curiosity, what would be the use case for deleting a topic rather than not showing it?

MaartenGr avatar Aug 11 '22 05:08 MaartenGr

If I'm not mistaken, merging the topic with -1 would "delete" it in a sense, but the ordering of your topics would change too.

topic_model.merge_topics(docs, topics, [-1, topic_to_delete])

leloykun avatar Sep 05 '22 20:09 leloykun

Due to inactivity, I'll be closing this for now. Let me know if you have any other questions related to this and I'll make sure to re-open the issue!

MaartenGr avatar Sep 27 '22 08:09 MaartenGr