Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

affinity propagation cosine similarity python

# credit to Stack Overflow user in the source link
import numpy as np
from sklearn.metrics.pairwise import cosine_distances

# some dummy data
word_vectors = np.random.random((77, 300))

word_cosine = cosine_distances(word_vectors)
affprop = AffinityPropagation(affinity = 'precomputed', damping = 0.5)
af = affprop.fit(word_cosine)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #affinity #propagation #cosine #similarity #python
ADD COMMENT
Topic
Name
5+9 =