similar topics has topic -1 #773
Answered
by
MaartenGr
aminathshausan
asked this question in
Q&A
|
Hi
Is there a way I can ignore Topic -1. Thanks |
Answered by
MaartenGr
Oct 11, 2022
Replies: 1 comment 1 reply
|
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]
similar_topics = [topic_list[1:][index] for index in ids][::-1] |
1 reply
Answer selected by
aminathshausan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is currently not possible but you can adapt the code such that it ignores the outlier: