<div dir="ltr"><div><div><div>hey Richard<br><br></div>This works as a charm.<br></div><br>Thanks<br></div>Rishabh<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 4, 2015 at 10:21 PM, Richard Tsai <span dir="ltr"><<a href="mailto:richard9404@gmail.com" target="_blank">richard9404@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Rishabh,<br>
<br>
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 <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html#scipy.cluster.hierarchy.linkage" target="_blank">http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html#scipy.cluster.hierarchy.linkage</a><br>
<br>
Regards,<br>
Richard<br>
<br>
> 在 2015年3月4日,20:56,Rishabh SHARMA <<a href="mailto:rishabh.sharma.gunner@gmail.com">rishabh.sharma.gunner@gmail.com</a>> 写道:<br>
<div><div class="h5">><br>
> Hello<br>
> I have this question,could someone help?<br>
><br>
> I am using scipy.cluster.hiearchical<br>
> ***I have a distance matrix in squareform  't' as<br>
> array([[  0.00000000e+00,   3.44600000e+03,   6.75000000e+02,<br>
>            2.06000000e+03,   2.24205600e+06],<br>
>         [  3.44600000e+03,   0.00000000e+00,   2.77300000e+03,<br>
>            1.75000000e+03,   2.23959500e+06],<br>
>         [  6.75000000e+02,   2.77300000e+03,   0.00000000e+00,<br>
>            1.49100000e+03,   2.24154200e+06],<br>
>         [  2.06000000e+03,   1.75000000e+03,   1.49100000e+03,<br>
>            0.00000000e+00,   2.24127000e+06],<br>
>         [  2.24205600e+06,   2.23959500e+06,   2.24154200e+06,<br>
>            2.24127000e+06,   0.00000000e+00]])<br>
><br>
> ***I used this cmd<br>
> z=linkage(t,method='complete') //t is the above matrix<br>
> z<br>
> array([[  0.00000000e+00,   2.00000000e+00,   1.39718861e+03,<br>
>            2.00000000e+00],<br>
>         [  1.00000000e+00,   3.00000000e+00,   3.53484724e+03,<br>
>            2.00000000e+00],<br>
>         [  5.00000000e+00,   6.00000000e+00,   5.85696654e+03,<br>
>            4.00000000e+00],<br>
>         [  4.00000000e+00,   7.00000000e+00,   5.00927065e+06,<br>
>            5.00000000e+00]])<br>
><br>
> **Question: why in the first row of z where objects 0,2 are merged the<br>
> distance is shown as 1.397e+3[3rd element of 1st row] whereas it should<br>
> the distance given by t[0][2] as in distance matrix(these objects are<br>
> original objects/leaf nodes)<br>
><br>
> Thanks<br>
><br>
><br>
> PS: I posted the question in user list,but no one seems to have the answer.In any case sorry for spamming dev list.<br>
</div></div>> _______________________________________________<br>
> SciPy-Dev mailing list<br>
> <a href="mailto:SciPy-Dev@scipy.org">SciPy-Dev@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/scipy-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/scipy-dev</a><br>
<br>
_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@scipy.org">SciPy-Dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/scipy-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/scipy-dev</a><br>
</blockquote></div><br></div>