You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using GMM on a singe population (list), with version 0.16.
I get the following error, after calling the score_sample function:
'The shape of X is not compatible with self'
When digging a little bit, I found that what used to be, in the previous versions:
X = np.asarray(X)
if X.ndim == 1:
X = X[:, np.newaxis]
if X.size == 0:
return np.array([]), np.empty((0, self.n_components))
if X.shape[1] != self.means_.shape[1]:
raise ValueError('The shape of X is not compatible with self')
Is now:
X = check_array(X)
if X.ndim == 1:
X = X[:, np.newaxis]
if X.size == 0:
return np.array([]), np.empty((0, self.n_components))
if X.shape[1] != self.means_.shape[1]:
raise ValueError('The shape of X is not compatible with self')
This changes everything, as when you use it on a list, np.asarray returns a 1d array, which is then turned to a 2d array of shape (n,1) by the next lines, and the array is in the correct format. Whereas check_array turns our list into a (1,n) array, which leads to the error.
Am I getting this wrong or is this indeed what the problem is ? And in this case it's probably a bug in the latest release.
This is a problem with ndim=1, not lists. I am against dropping support for X of shape (n_samples,) (I know @GaelVaroquaux has somewhat different views). but we did support it in many places before, and I think it is better to make the support consistent (just working on that).
Activity
amueller commentedon Apr 3, 2015
Argh, it is an error.
xuewei4d commentedon Apr 3, 2015
I would like to try to fix it, but the docstring of
score_samplesaidMaybe we should stick to that X must be [n_sample, n_feature] 2D array ? That means the input cannot be a list?
amueller commentedon Apr 3, 2015
This is a problem with ndim=1, not lists. I am against dropping support for X of shape
(n_samples,)(I know @GaelVaroquaux has somewhat different views). but we did support it in many places before, and I think it is better to make the support consistent (just working on that).amueller commentedon Apr 3, 2015
There was a related issue recently but I can't find it :-/
amueller commentedon Apr 3, 2015
#4466.
atabakd commentedon Jul 5, 2015
Hey,
Can I ask if there is some kind of a workaround?
for now, I just did this:
amueller commentedon Jul 12, 2015
simple workaround: don't use 1d arrays ;)
amueller commentedon Sep 9, 2015
Fixed by #5152 (somewhat). It warns to use 2d X now and then breaks. I don't think we should back-fix this.