[scikit-learn] Spherical Kmeans #OT

Michael Eickenberg michael.eickenberg at gmail.com
Mon Jun 27 19:20:08 EDT 2016


You could do

from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import Normalizer
from sklearn.cluster import KMeans   # (or e.g. MiniBatchKMeans)

spherical_kmeans = make_pipeline(Normalizer(), KMeans(n_clusters=5))



On Tue, Jun 28, 2016 at 12:28 AM, JAGANADH G <jaganadhg at gmail.com> wrote:

> Hi Fred and Michel,
>
> Thanks for the reply . I think I git this and am able to run it.
>
>
> Best
> Jagan
>
>
> On Mon, Jun 27, 2016 at 1:03 PM, Fred Mailhot <fred.mailhot at gmail.com>
> wrote:
>
>> Per the example here:
>>
>> http://scikit-learn.org/stable/auto_examples/text/document_clustering.html
>>
>> if your inputs are normalized, sklearn's kmeans behaves like sperical
>> kmeans (unless I'm misunderstanding something, which is certainly possible,
>> caveat lector, &c )...
>> On Jun 27, 2016 12:13 PM, "Michael Eickenberg" <
>> michael.eickenberg at gmail.com> wrote:
>>
>>> hmm, not an answer, and off the top of my head:
>>> if you normalize your data points to l2 norm equal 1, and then use
>>> standard kmeans with euclidean distance (which then amounts to 2 - 2
>>> cos(angle between points)) would this be enough for your purposes? (with a
>>> bit of luck there may even be some sort of correspondence)
>>>
>>> Michael
>>>
>>> On Monday, June 27, 2016, JAGANADH G <jaganadhg at gmail.com> wrote:
>>>
>>>> Hi ,
>>>> is there any Python package available for experiment with Sperical
>>>> Kmeans ?
>>>>
>>>>
>>>> --
>>>> **********************************
>>>> JAGANADH G
>>>> http://jaganadhg.in
>>>> *ILUGCBE*
>>>> http://ilugcbe.org.in
>>>>
>>>
>>> _______________________________________________
>>> scikit-learn mailing list
>>> scikit-learn at python.org
>>> https://mail.python.org/mailman/listinfo/scikit-learn
>>>
>>>
>> _______________________________________________
>> scikit-learn mailing list
>> scikit-learn at python.org
>> https://mail.python.org/mailman/listinfo/scikit-learn
>>
>>
>
>
> --
> **********************************
> JAGANADH G
> http://jaganadhg.in
> *ILUGCBE*
> http://ilugcbe.org.in
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20160628/da76284c/attachment-0001.html>


More information about the scikit-learn mailing list