Skip to content

Instantly share code, notes, and snippets.

@dataman-git
dataman-git / install
Last active February 23, 2023 00:19
install
#!pip install bertopic
# You may want to install more depending on the transformers and language backends that you will be using. The possible installations are:
#!pip install bertopic[flair]
#!pip install bertopic[gensim]
#!pip install bertopic[spacy]
#!pip install bertopic[use]
@dataman-git
dataman-git / visualize_barchart
Last active February 23, 2023 00:28
visualize_barchart
topic_model.visualize_barchart()
@dataman-git
dataman-git / visualize_hierarchy
Last active February 23, 2023 00:26
visualize_hierarchy
topic_model.visualize_hierarchy()
@dataman-git
dataman-git / visualize_topics
Last active February 23, 2023 00:25
visualize_topics
topic_model.visualize_topics()
@dataman-git
dataman-git / get_document_info
Last active February 23, 2023 00:24
get_document_info
topic_model.get_document_info(docs)
@dataman-git
dataman-git / get_topic
Last active February 23, 2023 00:23
get_topic
topic_model.get_topic(0)
@dataman-git
dataman-git / get_topic_info
Last active February 23, 2023 00:22
get_topic_info
topic_model.get_topic_info()
@dataman-git
dataman-git / save
Last active February 23, 2023 00:21
save
topic_model.save("/content/gdrive/My Drive/data/gensim/ag_news_bertopic")
@dataman-git
dataman-git / topic_model
Last active February 23, 2023 00:20
topic_model
from bertopic import BERTopic
docs = train['Description']
topic_model = BERTopic()
topics, probs = topic_model.fit_transform(docs)
@dataman-git
dataman-git / load
Last active February 23, 2023 00:19
load
import pandas as pd
import numpy as np
pd.set_option('display.max_colwidth', -1)
train = pd.read_csv("/content/gdrive/My Drive/data/gensim/ag_news_train.csv")