Skip to content

Commit 169a966

Browse files
committed
fix bug in wordcloud func
1 parent 233808c commit 169a966

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

stream_topic/visuals/visuals.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
from ..models.abstract_helper_models.base import BaseModel, TrainingStatus
55
from ..utils import TMDataset
6-
from ._interactive import (_visualize_topic_model_2d,
7-
_visualize_topic_model_3d, _visualize_topics_2d,
8-
_visualize_topics_3d)
6+
from ._interactive import (
7+
_visualize_topic_model_2d,
8+
_visualize_topic_model_3d,
9+
_visualize_topics_2d,
10+
_visualize_topics_3d,
11+
)
912
from ._octis_visuals import OctisWrapperVisualModel
1013

1114

@@ -43,7 +46,7 @@ def visualize_topics_as_wordclouds(
4346
hasattr(model, "topic_dict") and model._status == TrainingStatus.SUCCEEDED
4447
), "Model must have been trained with topics extracted."
4548

46-
topics = model.get_topics()
49+
topics = model.topic_dict
4750

4851
for topic_id, topic_words in topics.items():
4952
# Generate a word frequency dictionary for the topic
@@ -153,24 +156,24 @@ def visualize_topics(
153156
use_average: bool = True,
154157
):
155158
"""
156-
Visualize topics in either 2D or 3D space using UMAP, t-SNE, or PCA dimensionality reduction techniques.
157-
158-
Args:
159-
model (AbstractModel): The trained topic model instance.
160-
model_output (dict, optional): The output of the topic model, typically including topic-word distributions and document-topic distributions. Required if the model does not have an 'output' attribute.
161-
dataset (TMDataset, optional): The dataset used for training the topic model. Required if the model does not have an 'output' attribute.
162-
three_dim (bool, optional): Flag to visualize in 3D if True, otherwise in 2D. Defaults to False.
163-
reduce_first (bool, optional): Indicates whether to perform dimensionality reduction on embeddings before computing topic centroids. Defaults to False.
164-
reducer (str, optional): Choice of dimensionality reduction technique. Supported values are 'umap', 'tsne', and 'pca'. Defaults to 'umap'.
165-
port (int, optional): The port number on which the visualization dashboard will run. Defaults to 8050.
166-
embedding_model_name (str, optional): Name of the embedding model used for generating document embeddings. Defaults to "all-MiniLM-L6-v2".
167-
embeddings_folder_path (str, optional): Path to the folder containing precomputed embeddings. If not provided, embeddings will be computed on the fly.
168-
embeddings_file_path (str, optional): Path to the file containing precomputed embeddings. If not provided, embeddings will be computed on the fly.
169-
170-
171-
Returns:
172-
None
173-
The function launches a Dash server to visualize the topic model.
159+
Visualize topics in either 2D or 3D space using UMAP, t-SNE, or PCA dimensionality reduction techniques.
160+
161+
Args:
162+
model (AbstractModel): The trained topic model instance.
163+
model_output (dict, optional): The output of the topic model, typically including topic-word distributions and document-topic distributions. Required if the model does not have an 'output' attribute.
164+
dataset (TMDataset, optional): The dataset used for training the topic model. Required if the model does not have an 'output' attribute.
165+
three_dim (bool, optional): Flag to visualize in 3D if True, otherwise in 2D. Defaults to False.
166+
reduce_first (bool, optional): Indicates whether to perform dimensionality reduction on embeddings before computing topic centroids. Defaults to False.
167+
reducer (str, optional): Choice of dimensionality reduction technique. Supported values are 'umap', 'tsne', and 'pca'. Defaults to 'umap'.
168+
port (int, optional): The port number on which the visualization dashboard will run. Defaults to 8050.
169+
embedding_model_name (str, optional): Name of the embedding model used for generating document embeddings. Defaults to "all-MiniLM-L6-v2".
170+
embeddings_folder_path (str, optional): Path to the folder containing precomputed embeddings. If not provided, embeddings will be computed on the fly.
171+
embeddings_file_path (str, optional): Path to the file containing precomputed embeddings. If not provided, embeddings will be computed on the fly.
172+
173+
174+
Returns:
175+
None
176+
The function launches a Dash server to visualize the topic model.
174177
175178
"""
176179
if not isinstance(model, BaseModel):

0 commit comments

Comments
 (0)