“Affinitätspropagation Python” Code-Antworten

Affinitätspropagation Python

from sklearn.cluster import AffinityPropagation
import numpy as np

X = np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
clustering = AffinityPropagation(affinity = 'euclidean', random_state=5).fit(X)

labels = clustering.labels_ # label to each element
centers = clustering.cluster_centers_ # center of each cluster

# if you need a distance different from euclidean
# calculate your custom, pairwise distance among vectors 
# and store them into a matrix M. 
# Note: cluster_centers are no longer available

clustering = AffinityPropagation(affinity='precomputed', random_state=5).fit(M)
wolf-like_hunter

Affinitätspropagation Python


S
array([[ 1.        ,  0.08276253,  0.16227766,  0.47213595,  0.64575131],
       [ 0.08276253,  1.        ,  0.56776436,  0.74456265,  0.09901951],
       [ 0.16227766,  0.56776436,  1.        ,  0.47722558,  0.58257569],
       [ 0.47213595,  0.74456265,  0.47722558,  1.        ,  0.87298335],
       [ 0.64575131,  0.09901951,  0.58257569,  0.87298335,  1.        ]])

Magnificent Mantis

Ähnliche Antworten wie “Affinitätspropagation Python”

Fragen ähnlich wie “Affinitätspropagation Python”

Weitere verwandte Antworten zu “Affinitätspropagation Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen