Skip to content
Discussion options

You must be logged in to vote

That is currently not possible but you can adapt the code such that it ignores the outlier:

search_term = "my_search_term"
top_n = 5

topic_list = list(topic_model.topic_representations_.keys())
topic_list.sort()

# Extract search_term embeddings and compare with topic embeddings
search_embedding = topic_model._extract_embeddings([search_term],
                                            method="word",
                                            verbose=False).flatten()
sims = cosine_similarity(search_embedding.reshape(1, -1), topic_model.topic_embeddings_[1:]).flatten()

# Extract topics most similar to search_term
ids = np.argsort(sims)[-top_n:]
similarity = [sims[i] for i in ids][::-1]
s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aminathshausan
Comment options

Answer selected by aminathshausan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants