I have build a topic model with Bertopic. After getting topic how could I assign them to dataset.
My main aim is to convert unsupervised topic modelling to supervised multi label classification problem.
You can write the topics directly with the original data set in a dataframe because the topics are output in the same order as they are contained in the docs.
import pandas as pd
model = BERTopic.load('path')
df = pd.DataFrame({ 'topic': model.topics_,'document': docs['id']})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With