I new to topic modeling
and I'm trying to use BERTopic
inside of PyCharm
. I'm struggling to get any type of visualization to work inside of PyCharm
with BERTopic
.
Here is my current code:
import pickle
from umap import UMAP
from hdbscan import HDBSCAN
from bertopic import BERTopic
from sent2vec.vectorizer import Vectorizer
from sentence_transformers import SentenceTransformer
from sklearn.feature_extraction.text import CountVectorizer
# 6000 articles about cryptocurrencies
with open('all_articles', 'rb') as file_in:
random_articles = pickle.load(file_in)
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
umap_model = UMAP(n_neighbors=3,
n_components=3,
min_dist=0.05)
hdbscan_model = HDBSCAN(min_cluster_size=80,
min_samples=40,
gen_min_span_tree=True,
prediction_data=True)
vectorizer_model = CountVectorizer(ngram_range=(1, 2),
stop_words='english')
model = BERTopic(
umap_model=umap_model,
hdbscan_model=hdbscan_model,
embedding_model=embedding_model,
vectorizer_model=vectorizer_model,
top_n_words=5,
language='english',
calculate_probabilities=True,
verbose=True
)
topics, probs = model.fit_transform(random_articles)
# this produces nothing
model.visualize_topics(top_n_topics=5)
I found this issue on visualization not working within PyCharm
with BERTopic
. This issue wasn't useful in solving my issue.
How do I get something to visualize inside of PyCharm
?