1
$\begingroup$

I am using sklearn affinity propagation algorithm as below.

affprop = sklearn.cluster.AffinityPropagation(affinity="precomputed", damping=0.5)

I also have a similarity matrix created for the data I am using. Now I want to use my similarity matrix to use in the affinity propagation model.

In sklearn they have different methods for this such as fit, fit_predict, predict. So, I'm not sure what to use.

Is it correct if I use,

affprop.fit(my similarity matrix)
$\endgroup$
  • $\begingroup$ For people who downvote please tell me what's wrong in this question $\endgroup$ – Smith Volka Aug 26 '17 at 13:36
2
$\begingroup$

It is correct to use as you indicated.

For example, in below , I use levenshtein for make similarity matrix. then use this matrix for clustring by affinity algorithm.

lev_similarity = -1*np.array([[distance.levenshtein(w1,w2) for w1 in words]
                              for w2 in words])

af = affprop.fit(lev_similarity)
| improve this answer | |
$\endgroup$

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.