In short, no, monkey patching cosine_similarity in place of
euclidean_distances will not work. See for instance this StackOverflow
post:
http://stats.stackexchange.com/questions/81481/why-does-k-means-clustering-algorithm-use-only-euclidean-distance-metric

You could try out this Kernel KMeans implementation:
https://github.com/scikit-learn/scikit-learn/pull/5483

On 3 June 2016 at 05:24, JAGANADH G <[email protected]> wrote:

> Hi Team,
> I was trying to use cosine similarity with KMeans. The code which I used
> to achieve is available here.
> https://gist.github.com/jaganadhg/b3f6af86ad99bf6e9bb7be21e5baa1b5
>
> Is it the right way to achieve the same ? I know that cosine is not
> directly supported in sklearn KMeans. But after skimming through the code I
> was thinking that this will work ;-)
>
> --
> **********************************
> JAGANADH G
> http://jaganadhg.in
> *ILUGCBE*
> http://ilugcbe.org.in
>
> _______________________________________________
> scikit-learn mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
_______________________________________________
scikit-learn mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scikit-learn

Reply via email to