10000 QDA may meet broken 2d array · Issue #4006 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

QDA may meet broken 2d array #4006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MidoriYakumo opened this issue Dec 26, 2014 · 6 comments · Fixed by #4057
Closed

QDA may meet broken 2d array #4006

MidoriYakumo opened this issue Dec 26, 2014 · 6 comments · Fixed by #4057
Labels
Milestone

Comments

@MidoriYakumo
Copy link
>>> sklearn.__version__
'0.16-git'

For my dataset it gives:

  File "/usr/lib64/python3.4/site-packages/sklearn/qda.py", line 148, in _decision_function
    return (-0.5 * (norm2 + np.sum(np.log(self.scalings_), 1))
AttributeError: 'numpy.ndarray' object has no attribute 'log'

When

qda.py:134:         self.scalings_ = np.asarray(scalings)

It shows that scalings is a 2d array in shape of (0..23, 0..23, 0..23, 0..6)

@agramfort
Copy link
Member

close if it was fixed by #3755 I just merged.

@amueller
Copy link
Member
amueller commented Jan 6, 2015

This could be caused by dtype='object'.

@amueller
Copy link
Member
amueller commented Jan 6, 2015

@MidoriYakumo can you give us X.dtype for your data?

@MidoriYakumo
Copy link
Author

I did not store that data but it is true that bad shape caused this error, a normal 2d "array in array" can be automatically and safely converted by numpy, I think.

@MidoriYakumo
Copy link
Author
Python 2.7.9 (default, Dec 13 2014, 18:02:08) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
np>>a=np.array([1,2,3])
>>> b=np.array([1,2])
>>> c=np.array([a,a,b])
>>> c
array([array([1, 2, 3]), array([1, 2, 3]), array([1, 2])], dtype=object)
>>> np.log(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'numpy.ndarray' object has no attribute 'log'
>>> d=np.array([a,a,a])
>>> np.log(d)
array([[ 0.        ,  0.69314718,  
8000
1.09861229],
       [ 0.        ,  0.69314718,  1.09861229],
       [ 0.        ,  0.69314718,  1.09861229]])

@amueller amueller added the Bug label Jan 7, 2015
@amueller
Copy link
Member
amueller commented Jan 7, 2015

Ok, I'm working on it in #4057.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0