{"action":"opened","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5614","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5614/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5614/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5614/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/5614","id":113977412,"number":5614,"title":"Ward FeatureAgglomeration:  Userwarning n_component, causes ward to be unstructured","user":{"login":"michaelbernier","id":1392234,"avatar_url":"https://avatars.githubusercontent.com/u/1392234?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelbernier","html_url":"https://github.com/michaelbernier","followers_url":"https://api.github.com/users/michaelbernier/followers","following_url":"https://api.github.com/users/michaelbernier/following{/other_user}","gists_url":"https://api.github.com/users/michaelbernier/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelbernier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelbernier/subscriptions","organizations_url":"https://api.github.com/users/michaelbernier/orgs","repos_url":"https://api.github.com/users/michaelbernier/repos","events_url":"https://api.github.com/users/michaelbernier/events{/privacy}","received_events_url":"https://api.github.com/users/michaelbernier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-29T04:21:39Z","updated_at":"2015-10-29T04:21:39Z","closed_at":null,"body":"When using FeatureAgglomeration with Ward linkage on a 3d dataset, I setup with adjacency matrix with grid_to_graph ( output seems fine ). However, when running the FeatureAgglomeration, this warning is issued:\r\n\"UserWarning: the number of connected components of the connectivity matrix is 158 > 1. Completing it to avoid stopping the tree early.\"\r\n\r\nThe 158 number is odd, but everything runs well, except that the outputted labels are unstructured (as if the connectivity matrix is not set correctly). \r\n\r\nMy code:\r\n------\r\nshape=mask.shape  //  ( 3d image of 101681 non-zero voxel, 96 x 114  x 96)\r\ndata = masker.fit_transform(X)    //   (list of 3d image  63 times 96 x 114  x 96)\r\n\r\nconnectivity = image.grid_to_graph(n_x=shape[0], n_y=shape[1],\r\n                                       n_z=shape[2], mask=mask)\r\nprint connectivity.nnz     // gives 549509 non-zero connections\r\n\r\nward = FeatureAgglomeration(n_clusters=500, connectivity=connectivity,\r\n                                linkage='ward', memory='nilearn_cache')\r\nward.fit(fmri_masked)\r\n\r\n---\r\nOUTPUT:\r\n\"UserWarning: the number of connected components of the connectivity matrix is 158 > 1. Completing it to avoid stopping the tree early.\"\r\n"}}