Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

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)

Comment

PREVIOUS NEXT
Code Example
Python :: python string copy 
Python :: can I activate a function inside the definition of the same function 
Python :: replace substrings to float 
Python :: sleep python 
Python :: r Return each result with an index 
Python :: python function guts 
Python :: cannot cast type smallint to boolean django 
Python :: python autotrader web 
Python :: when was python 3.8 released 
Python :: pandas crosstab function(counting) frequencies 
Python :: how to insert an array as a parameter in python 
Python :: if ele in python 
Python :: how can i get the data from a queryset in django template 
Python :: 198727191002 
Python :: how to open Website from CMD using python 
Python :: csv file python 
Python :: threading pass keyword args example 
Python :: write python code in ansible 
Python :: calculate iou of two rectangles 
Python :: Adding new nested object using Shallow copy 
Python :: tables in django 
Python :: python yield async await 
Python :: python variable and data structure 
Python :: Reading Excel and other Microsoft Office files 
Python :: 0 in python 
Python :: python run only when list is bigger 
Python :: eastcoders: django-meta-class 
Python :: how to download a website using python 
Python :: how to minimisze python console 
Python :: sqlalchemy filter getattr 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =