[SciPy-Dev] Hiearchical Clustering issue
Richard Tsai
richard9404 at gmail.com
Wed Mar 4 11:51:36 EST 2015
Hi Rishabh,
hierarchy.linkage requires its first argument to be a *condensed* distance matrix, which can be obtained using some functions in spatial.distance. If a 2d array is provided, it will be considered as an observation vectors array. Check the docs here http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html#scipy.cluster.hierarchy.linkage
Regards,
Richard
> 在 2015年3月4日,20:56,Rishabh SHARMA <rishabh.sharma.gunner at gmail.com> 写道:
>
> Hello
> I have this question,could someone help?
>
> I am using scipy.cluster.hiearchical
> ***I have a distance matrix in squareform 't' as
> array([[ 0.00000000e+00, 3.44600000e+03, 6.75000000e+02,
> 2.06000000e+03, 2.24205600e+06],
> [ 3.44600000e+03, 0.00000000e+00, 2.77300000e+03,
> 1.75000000e+03, 2.23959500e+06],
> [ 6.75000000e+02, 2.77300000e+03, 0.00000000e+00,
> 1.49100000e+03, 2.24154200e+06],
> [ 2.06000000e+03, 1.75000000e+03, 1.49100000e+03,
> 0.00000000e+00, 2.24127000e+06],
> [ 2.24205600e+06, 2.23959500e+06, 2.24154200e+06,
> 2.24127000e+06, 0.00000000e+00]])
>
> ***I used this cmd
> z=linkage(t,method='complete') //t is the above matrix
> z
> array([[ 0.00000000e+00, 2.00000000e+00, 1.39718861e+03,
> 2.00000000e+00],
> [ 1.00000000e+00, 3.00000000e+00, 3.53484724e+03,
> 2.00000000e+00],
> [ 5.00000000e+00, 6.00000000e+00, 5.85696654e+03,
> 4.00000000e+00],
> [ 4.00000000e+00, 7.00000000e+00, 5.00927065e+06,
> 5.00000000e+00]])
>
> **Question: why in the first row of z where objects 0,2 are merged the
> distance is shown as 1.397e+3[3rd element of 1st row] whereas it should
> the distance given by t[0][2] as in distance matrix(these objects are
> original objects/leaf nodes)
>
> Thanks
>
>
> PS: I posted the question in user list,but no one seems to have the answer.In any case sorry for spamming dev list.
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
More information about the SciPy-Dev
mailing list