{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4877","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4877/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4877/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4877/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/4877","id":89653329,"number":4877,"title":"undesirable behavior from check_array function when passed a 1D numpy array in 0.16.1","user":{"login":"JLConawayII","id":7500794,"avatar_url":"https://avatars.githubusercontent.com/u/7500794?v=3","gravatar_id":"","url":"https://api.github.com/users/JLConawayII","html_url":"https://github.com/JLConawayII","followers_url":"https://api.github.com/users/JLConawayII/followers","following_url":"https://api.github.com/users/JLConawayII/following{/other_user}","gists_url":"https://api.github.com/users/JLConawayII/gists{/gist_id}","starred_url":"https://api.github.com/users/JLConawayII/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JLConawayII/subscriptions","organizations_url":"https://api.github.com/users/JLConawayII/orgs","repos_url":"https://api.github.com/users/JLConawayII/repos","events_url":"https://api.github.com/users/JLConawayII/events{/privacy}","received_events_url":"https://api.github.com/users/JLConawayII/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-19T20:27:22Z","updated_at":"2015-06-20T03:01:22Z","closed_at":null,"body":"I'm going to be using Gaussian Mixture Models for my research and I thought I would input some examples to see how the package worked. When I tried running the 1D Gaussian Mixture Example located here http://www.astroml.org/book_figures/chapter4/fig_GMM_1D.html it kicked back this error in Pycharm:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/jconaway/Research/Kepler_Analysis_2/gaussian_mixture_example.py\", line 86, in <module>\r\n    logprob, responsibilities = M_best.score_samples(x)\r\n  File \"/home/jconaway/anaconda3/lib/python3.4/site-packages/sklearn/mixture/gmm.py\", line 315, in score_samples\r\n    raise ValueError('The shape of X  is not compatible with self')\r\nValueError: The shape of X  is not compatible with self\r\n\r\nProcess finished with exit code 1\r\n\r\nI figured it should have worked as-is, so I did some exploring as to why it wasn't working correctly. I found that when M_best.score_samples(x) reaches X = check_array(X) on line 309 of gmm.py, it looks like it doesn't return the correct array. Here's some doodling around I did with some arbitrary arrays:\r\n\r\nIn [1]: import numpy as np\r\n\r\nIn [2]: x = np.linspace(-3,3,7)\r\n\r\nIn [3]: y = x[:,np.newaxis]\r\n\r\nIn [4]: x\r\nOut[4]: array([-3., -2., -1.,  0.,  1.,  2.,  3.])\r\n\r\nIn [5]: y\r\nOut[5]: \r\narray([[-3.],\r\n       [-2.],\r\n       [-1.],\r\n       [ 0.],\r\n       [ 1.],\r\n       [ 2.],\r\n       [ 3.]])\r\n\r\nIn [6]: y.shape[1]\r\nOut[6]: 1\r\n\r\nIn [7]: from sklearn.utils import validation\r\n\r\nIn [8]: Q = np.array([1,2,3,4,5])\r\n\r\nIn [9]: q = validation.check_array(Q)\r\n\r\nIn [10]: q\r\nOut[10]: array([[1, 2, 3, 4, 5]])\r\n\r\nIn [11]: s = q[:,np.newaxis]\r\n\r\nIn [12]: s\r\nOut[12]: array([[[1, 2, 3, 4, 5]]])\r\n\r\nWhen I went back to the example and changed it to this:\r\n\r\ns = x[:,np.newaxis]\r\nlogprob, responsibilities = M_best.score_samples(s)\r\n\r\nit worked fine. That's as far as I've gotten with this. Hope it's helpful."},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/113700183","html_url":"https://github.com/scikit-learn/scikit-learn/issues/4877#issuecomment-113700183","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4877","id":113700183,"user":{"login":"xuewei4d","id":1180956,"avatar_url":"https://avatars.githubusercontent.com/u/1180956?v=3","gravatar_id":"","url":"https://api.github.com/users/xuewei4d","html_url":"https://github.com/xuewei4d","followers_url":"https://api.github.com/users/xuewei4d/followers","following_url":"https://api.github.com/users/xuewei4d/following{/other_user}","gists_url":"https://api.github.com/users/xuewei4d/gists{/gist_id}","starred_url":"https://api.github.com/users/xuewei4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuewei4d/subscriptions","organizations_url":"https://api.github.com/users/xuewei4d/orgs","repos_url":"https://api.github.com/users/xuewei4d/repos","events_url":"https://api.github.com/users/xuewei4d/events{/privacy}","received_events_url":"https://api.github.com/users/xuewei4d/received_events","type":"User","site_admin":false},"created_at":"2015-06-20T03:01:22Z","updated_at":"2015-06-20T03:01:22Z","body":"Sure. I repeated this code. @JLConawayII, correct me if I am wrong. \r\n\r\n gmm ```fits``` on the data of shape (n, 1), then ```score_samples``` on data of shape (n, ), which is further transformed into (1, n) by ```check_array```. Then it raises an error.\r\n\r\nIf ```check_array``` in #4511 does raise an error, then we leave the problem to the user. When would you merge #4511, until 1.0 ? @amueller  \r\nBut before we merge ```check_array```, I think we'd better raise an error whenever encounters 1D data."}}