I am hoping to use affinity propagation to cluster my data using sklearn. But I came across a question whether to use a distance matrix or similarity matrix in the fit method.

Please let me know what is suitable to use?

  • $\begingroup$ Did you check the paper and the source code? $\endgroup$ – Has QUIT--Anony-Mousse Sep 19 '17 at 19:01
  • $\begingroup$ I did check the source code of sklearn. However, they are inserting some random data, so it is bit difficult to understand. $\endgroup$ – Volka Sep 20 '17 at 4:51
  • $\begingroup$ @Anony-Mousse Can you please tell me if you know? $\endgroup$ – Volka Sep 21 '17 at 0:58
  • $\begingroup$ I'd have to read the paper. $\endgroup$ – Has QUIT--Anony-Mousse Sep 21 '17 at 6:44

According to sklearn.cluster.AP (in case in AP chosen affinity = "precomputed") the method "fit" requires X where X is matrix of similarities / affinities, that is, if distance matrix is estimated, use as:

X $ = matrix\ of\ similarities = -distance\ matrix$.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.