scikit learn - Affinity Propagation (sklearn) - strange behavior -


trying use affinity propagation simple clustering task:

from sklearn.cluster import affinitypropagation c = [[0], [0], [0], [0], [0], [0], [0], [0]] af = affinitypropagation (affinity = 'euclidean').fit (c) print (af.labels_) 

i strange result: [0 1 0 1 2 1 1 0]

i expect have samples in same cluster, in case:

c = [[0], [0], [0]] af = affinitypropagation (affinity = 'euclidean').fit (c) print (af.labels_) 

which indeed puts samples in same cluster: [0 0 0]

what missing?

thanks

i believe because problem ill-posed (you pass lots of same point algorithm trying find similarity between different points). affinitypropagation doing matrix math under hood, , similarity matrix (which zeros) nastily degenerate. in order not error out, implementation adds small random matrix similarity matrix, preventing algorithm quitting when encounters 2 of same point.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -