Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

affinity propagation cosine similarity python


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

# using eucliden distance
affprop = AffinityPropagation(affinity='euclidean', damping=0.5)
af = affprop.fit(word_vectors)

# using cosine
from sklearn.metrics.pairwise import cosine_distances
word_cosine = cosine_distances(word_vectors)
affprop = AffinityPropagation(affinity='precomputed', damping=0.5)
af = affprop.fit(word_cosine)

Source by codefantasy.org #
 
PREVIOUS NEXT
Tagged: #affinity #propagation #cosine #similarity #python
ADD COMMENT
Topic
Name
5+7 =