AffinityPropagation .labels_ vs .predict()
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Secret Catacombs
--
Chapters
00:00 Question
00:37 Accepted answer (Score 4)
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/5390...
Question links:
[image]: https://i.stack.imgur.com/A0vr4.png
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #machinelearning #scikitlearn #clusteranalysis
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Secret Catacombs
--
Chapters
00:00 Question
00:37 Accepted answer (Score 4)
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/5390...
Question links:
[image]: https://i.stack.imgur.com/A0vr4.png
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #machinelearning #scikitlearn #clusteranalysis
#avk47
ACCEPTED ANSWER
Score 4
Don't use predict with any clustering except k-means-family.
If you do fit, the result is computed with affinity propagation.
If you invoke predict, it is not actually doing AP. Instead, it just finds the nearest exemplar for each point. That may, or may not, give the same results, as you have observed. Since near points are most likely responsible, this has a high chance of being correct - but it is not doing any form of affinity propagation, it is a nearest-neighbor classification to the exemplars.
k-means is fine because it uses the nearest-center logic. But that does not generally hold for clustering. In general, clustering algorithms cannot predict for out-of-sample data; you need a classififer for that.