{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7865","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7865/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7865/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7865/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/7865","id":189064891,"number":7865,"title":"Clustering with MiniBatchKMeans produces indexing error.","user":{"login":"stefdoerr","id":7935362,"avatar_url":"https://avatars.githubusercontent.com/u/7935362?v=3","gravatar_id":"","url":"https://api.github.com/users/stefdoerr","html_url":"https://github.com/stefdoerr","followers_url":"https://api.github.com/users/stefdoerr/followers","following_url":"https://api.github.com/users/stefdoerr/following{/other_user}","gists_url":"https://api.github.com/users/stefdoerr/gists{/gist_id}","starred_url":"https://api.github.com/users/stefdoerr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefdoerr/subscriptions","organizations_url":"https://api.github.com/users/stefdoerr/orgs","repos_url":"https://api.github.com/users/stefdoerr/repos","events_url":"https://api.github.com/users/stefdoerr/events{/privacy}","received_events_url":"https://api.github.com/users/stefdoerr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-11-14T09:30:18Z","updated_at":"2016-11-24T19:25:16Z","closed_at":null,"body":"#### Description\r\nClustering with MiniBatchKMeans produces indexing error.\r\n\r\nI have a crontab doing some clustering every hour. This error manifests around 4-5 times in a day. I assume the kmeans initialization is stochastic?\r\n\r\nUnfortunately right now I can't find a dataset for reproducing because the error happens stochastically on a dataset that is changing every hour. If I manage to find a reproducible dataset I will attach it to the issue. \r\n\r\n#### Steps/Code to Reproduce\r\n```python\r\nfrom sklearn.cluster import MiniBatchKMeans\r\nclusterobj = MiniBatchKMeans(n_clusters=1000)\r\nclusterobj.fit(datconcat)\r\n```\r\n\r\n#### Expected Results\r\nNo error\r\n\r\n#### Actual Results\r\n```pytb\r\nTraceback (most recent call last):\r\n  File \"metricdata.py\", line 160, in cluster\r\n    clusterobj.fit(datconcat)\r\n  File \"/shared/sdoerr/Software/anaconda3/lib/python3.5/site-packages/sklearn/cluster/k_means_.py\", line 1382, in fit\r\n    init_size=init_size)\r\n  File \"/shared/sdoerr/Software/anaconda3/lib/python3.5/site-packages/sklearn/cluster/k_means_.py\", line 683, in _init_centroids\r\n    x_squared_norms=x_squared_norms)\r\n  File \"/shared/sdoerr/Software/anaconda3/lib/python3.5/site-packages/sklearn/cluster/k_means_.py\", line 113, in _k_init\r\n    X[candidate_ids], X, Y_norm_squared=x_squared_norms, squared=True)\r\nIndexError: index 2772 is out of bounds for axis 0 with size 2772\r\n```\r\n\r\n#### Versions\r\n```\r\nLinux-3.10.0-327.13.1.el7.x86_64-x86_64-with-centos-7.2.1511-Core\r\nPython 3.5.2 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:53:06) \r\n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]\r\nNumPy 1.11.2\r\nSciPy 0.18.1\r\nScikit-Learn 0.18\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/262834965","html_url":"https://github.com/scikit-learn/scikit-learn/issues/7865#issuecomment-262834965","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7865","id":262834965,"user":{"login":"lesteve","id":1680079,"avatar_url":"https://avatars.githubusercontent.com/u/1680079?v=3","gravatar_id":"","url":"https://api.github.com/users/lesteve","html_url":"https://github.com/lesteve","followers_url":"https://api.github.com/users/lesteve/followers","following_url":"https://api.github.com/users/lesteve/following{/other_user}","gists_url":"https://api.github.com/users/lesteve/gists{/gist_id}","starred_url":"https://api.github.com/users/lesteve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lesteve/subscriptions","organizations_url":"https://api.github.com/users/lesteve/orgs","repos_url":"https://api.github.com/users/lesteve/repos","events_url":"https://api.github.com/users/lesteve/events{/privacy}","received_events_url":"https://api.github.com/users/lesteve/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T19:25:16Z","updated_at":"2016-11-24T19:25:16Z","body":"Thanks a lot @stefdoerr for providing the data. I can run reproduce the error in 0.18.1 and run without error in master with the following snippet:\r\n\r\n```py\r\nimport numpy as np\r\nfrom sklearn.cluster import MiniBatchKMeans\r\n\r\ndata = np.load('/tmp/data.npy')\r\nmb = MiniBatchKMeans(n_clusters=1000, random_state=39)\r\nmb.fit_transform(data)\r\n```"}}
{"actor":{"display_login":"lesteve"}}