我有一个数据集,并试图使用berTopic建模将其转换为主题,但问题是,我无法获得主题的所有结果。对于每个主题,berTopic只返回3个结果。
topic_model = BERTopic(verbose=True, embedding_model=embedding_model,
nr_topics = 'auto',
n_gram_range = (3,3),
top_n_words = 10,
calculate_probabilities=True,
seed_topic_list = topic_list,
)
topics, probs = topic_model.fit_transform(docs_test)
representative_doc = topic_model.get_representative_docs(topic#1)
representative_doc发布于 2021-11-24 14:19:58
可能有更优雅的解决方案,因为我不是专家,但我可以分享对我有效的解决方案(因为还没有答案):
" topics,probs = topic_model.fit_transform(docs_test)“返回主题。
因此,您可以将此输出和文档组合在一起。例如,使用以下命令将它们组合成一个(pandas.)数据帧
df = pd.DataFrame({'topic': topics, 'document': docs_test})现在,您可以为每个主题过滤此数据帧,以识别引用文档。
topic_0 = df[df.topic == 0]https://stackoverflow.com/questions/69740911
复制相似问题