<div dir="ltr">Sema,<div><br></div><div>It is a two step process (at least). Here is an example:</div><div><br></div><div>    from scipy.cluster import hierarchy</div><div><br></div>    Z = hierarchy.linkage(dm, metric='precomputed')<br>    labels = hierarchy.fcluster(Z, n_clusters, criterion='maxclust')<div><br></div><div>The labels array will have length n, and will look like [0, 0, 1, 2, 0, ...]. Typically, you have to choose the number of clusters (or some other criterion, see fcluster docs). You can do that by looking at the dendrogram plot with this command, which will make a matplotlib plot:</div><div><br></div><div>    hierarchy.dendrogram(Z)  # This has a bunch of useful keyword arguments too.</div><div><br></div><div>Happy clustering!</div><div>Kevin</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Feb 24, 2017 at 12:59 AM Sema Atasever <<a href="mailto:s.atasever@gmail.com">s.atasever@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div style="font-size:12.8px" class="gmail_msg"><div style="font-size:12.8px" class="gmail_msg">Dear SciPy list member,<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div><div style="font-size:12.8px" class="gmail_msg"><span style="font-size:12.8px" class="gmail_msg">I want to ask you about clustering usign scipy.cluster.hierarchy.</span><br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg"><div style="font-size:12.8px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg">I have a <b class="gmail_msg">distance matrix</b> n*n M where M_ij is the distance between object_i and object_j. You can see file format in the attachment --> (dm.csv)<br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg">I want to cluster these n objects with hierarchical clustering. </div><div style="font-size:12.8px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg">For this purpose i am usign this python code that you can see in the attachment (scipy_code.py) </div><div style="font-size:12.8px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-size:12.8px" class="gmail_msg">I want to ask that <span style="font-size:12.8px" class="gmail_msg">how can get clusters values in pdf format or text format and how many clusters did i get and what clusters includes what members?</span></div><div style="font-size:12.8px" class="gmail_msg"><span style="font-size:12.8px" class="gmail_msg"><br class="gmail_msg"></span></div><div style="font-size:12.8px" class="gmail_msg"><div id="m_8481904175153987329gmail-:1qi" class="m_8481904175153987329gmail-ii m_8481904175153987329gmail-gt m_8481904175153987329gmail-adP m_8481904175153987329gmail-adO gmail_msg" style="font-size:12.8px;margin-bottom:0px;margin-left:0px;padding-bottom:5px"><div id="m_8481904175153987329gmail-:1qh" class="m_8481904175153987329gmail-a3s m_8481904175153987329gmail-aXjCH m_8481904175153987329gmail-m15a6587da0525f8d gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">Thanks in Advance, <span style="font-size:12.8px" class="gmail_msg">Best regards.</span></div><div class="m_8481904175153987329gmail-yj6qo gmail_msg"></div></div></div></div><div class="m_8481904175153987329gmail-hq m_8481904175153987329gmail-gt m_8481904175153987329gmail-a10 gmail_msg" id="m_8481904175153987329gmail-:1hl" style="font-size:12.8px"></div></div></div></div>
_______________________________________________<br class="gmail_msg">
SciPy-User mailing list<br class="gmail_msg">
<a href="mailto:SciPy-User@python.org" class="gmail_msg" target="_blank">SciPy-User@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br class="gmail_msg">
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Kevin Gullikson<div>Data Scientist</div><div>Spark Cognition</div><div><br></div></div></div>