Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing for small number of topics. #229

Merged
merged 1 commit into from Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyLDAvis/_prepare.py
Expand Up @@ -163,7 +163,7 @@ def js_TSNE(distributions, **kwargs):
tsne : array, shape (`n_dists`, 2)
"""
dist_matrix = squareform(pdist(distributions, metric=_jensen_shannon))
model = TSNE(n_components=2, random_state=0, metric='precomputed', **kwargs)
model = TSNE(n_components=2, random_state=0, metric='precomputed', perplexity=min(len(dist_matrix)-1, 30), **kwargs)
return model.fit_transform(dist_matrix)


Expand Down Expand Up @@ -468,4 +468,4 @@ def to_dict(self):
'topic.order': self.topic_order}

def to_json(self):
return json.dumps(self.to_dict(), cls=NumPyEncoder)
return json.dumps(self.to_dict(), cls=NumPyEncoder)