[scikit-learn] Agglomerative clustering problem

Ariani A b.noushin7 at gmail.com
Tue Jul 11 14:22:43 EDT 2017


ِDear Uri,
Thanks. I just have a pairwise distance matrix and I want to implement it
so that each cluster has at least 40 data points. (in Agglomerative).
Does it work?
Thanks,
-Ariani

On Tue, Jul 11, 2017 at 1:54 PM, Uri Goren <uri at goren4u.com> wrote:

> Take a look at scipy's fcluster function.
> If M is a matrix of all of your feature vectors, this code snippet should
> work.
>
> You need to figure out what metric and algorithm work for you
>
>     from sklearn.metrics import pairwise_distance
>     from scipy.cluster import  hierarchy
>     X = pairwise_distance(M, metric=metric)
>     Z = hierarchy.linkage(X, algo, metric=metric)
>     C = hierarchy.fcluster(Z,threshold, criterion="distance")
>
> Best,
> Uri Goren
>
> On Tue, Jul 11, 2017 at 7:42 PM, Ariani A <b.noushin7 at gmail.com> wrote:
>
>> Hi all,
>> I want to perform agglomerative clustering, but I have no idea of number
>>  of clusters before hand. But I want that every cluster has at least 40
>> data points in it. How can I apply this to sklearn.agglomerative clusteri
>> ng?
>> Should I use dendrogram and cut it somehow? I have no idea how to relate
>> dendrogram to this and cutting it out. Any help will be appreciated!
>> I have to use agglomerative clustering!
>> Thanks,
>> -Ariani
>>
>> _______________________________________________
>> scikit-learn mailing list
>> scikit-learn at python.org
>> https://mail.python.org/mailman/listinfo/scikit-learn
>>
>>
>
>
> --
>
>
> *Uri Goren,Software innovator*
>
> *Phone: +972-507-649-650*
>
> *EMail: uri at goren4u.com <uri at goren4u.com>*
> *Linkedin: il.linkedin.com/in/ugoren/ <http://il.linkedin.com/in/ugoren/>*
>
> _______________________________________________
> 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/20170711/204e43e5/attachment-0001.html>


More information about the scikit-learn mailing list