Gael Varoquaux <gael.varoquaux@...> writes:
> > On Fri, Nov 11, 2011 at 10:32:07AM +1100, Robert Layton wrote: > > On 11 November 2011 09:53, Emanuele Olivetti wrote: > > > is there a way to get the full dendrogram from the hierarchical > > > clustering (Ward)? > > > The `ward_tree` function in sklearn/cluster/hierarchical.py should give > > you what you want. > > To add to this, if you are using the Ward object, the tree can be found > using the `children_` attribute of the object, that gives the pair of > children for each node in the tree. In addition, the number of leaves and > may be useful when traversing the tree, as it gives the maximum node > index at which they are no children. It is found as the `n_leaves_` > attribute of the Ward object. > > HTH, > > Gael > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Save $700 by Nov 18 > Register now > http://p.sf.net/sfu/rsa-sfdev2dev1 > I have the following data : d = ['aaa bb', 'aaa bb', 'aaa bb', 'aaa', 'aaa', 'ddd pp, 'ddd pp'] # and I cluster it in the following way w = Ward(n_clusters=2) w.fit(SomeVectorizer.fit_transform(d)) and I am getting the following n_labels which is understandable : [0, 0, 0, 0, 0, 1, 1] ==> first 4 and subsequent 2 docs are of the same cluster. I am not able to interpret the n_children_ values though : >>> w.children_ array([[ 5, 6], [ 3, 4], [ 2, 8], [ 1, 9], [ 0, 10], [ 7, 11]]) Can someone please walk me through the hierarchy. I am assuming there are in total 12 nodes numbered from 0 to 11. Assuming the children of parent node are 5 (left-child) and 6(right-child), who are the children of node-5 ? Any help is greatly appreciated. Thanks, Prasenjit ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnnow-d2d _______________________________________________ Scikit-learn-general mailing list Scikit-learn-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scikit-learn-general