Skip to content

Instantly share code, notes, and snippets.

@cydal
Created March 19, 2021 09:45
Show Gist options
  • Save cydal/f5c7b420a7e8cd3fa630e3b813ec5bde to your computer and use it in GitHub Desktop.
Save cydal/f5c7b420a7e8cd3fa630e3b813ec5bde to your computer and use it in GitHub Desktop.
from sknetwork.clustering import Louvain
## Tfidf vectorizer
tfidf_vectorizer_relevant = TfidfVectorizer(max_features=10000, ngram_range=(1,2))
x_relevant_transformed = tfidf_vectorizer_relevant.fit_transform(df_core["abstract"])
### Cosine Similarity
pairwise_similarity = x_relevant_transformed * x_relevant_transformed.T
louvain = Louvain()
labels = louvain.fit_transform(pairwise_similarity)
df_relevant["pred"] = labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment