Skip to content
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

ValueError: Expected 2D array, got 1D array instead: #21

Open
deekshithmr95 opened this issue Jan 5, 2018 · 8 comments
Open

ValueError: Expected 2D array, got 1D array instead: #21

deekshithmr95 opened this issue Jan 5, 2018 · 8 comments

Comments

@deekshithmr95
Copy link

I'm running test-object-detector.py on Windows 10 64bit with python 3.6.3
(added print statement's missing parenthesis)

python successfully downloaded and extracted 'UIUC Image Database for Car Detection'
but i'm getting error here

ValueError: Expected 2D array, got 1D array instead:
array=[].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Traceback (most recent call last):

how to resolve this issue?

@vermouthzjh
Copy link

In test-classifier.py, before pred = clf.predict(fd), add fd = [fd].

@alwansm
Copy link

alwansm commented Mar 23, 2018

hello @vermouthzjh I tried your method now i am getting :
Traceback (most recent call last): File "test-classifier.py", line 72, in <module> pred = clf.predict(fds) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\sklearn\linear_model\base.py", line 324, in predict scores = self.decision_function(X) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\sklearn\linear_model\base.py", line 305, in decision_function % (X.shape[1], n_features)) ValueError: X has 10206 features per sample; expecting 35721

@DeepInDeeper
Copy link

@alwansm Hi, I met the same problems.Have u solved it?

@chenqing
Copy link

The same problem to me

@LazyG
Copy link

LazyG commented Jan 2, 2019

bump

@HenryJunW
Copy link

Same problem, anyone solve it yet?

@Tomingz
Copy link

Tomingz commented Jun 28, 2019

fd=fd.reshape(1,-1)
pred=clf.predict(fd)
It works.
but I have another error:ValueError: X has 22032 features per sample; expecting 38916,how to fix it?

@fistyee
Copy link

fistyee commented Jul 16, 2020

fd=fd.reshape(1,-1)
pred=clf.predict(fd)
It works.
but I have another error:ValueError: X has 22032 features per sample; expecting 38916,how to fix it?

Same problem,, Do you solved this?

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

No branches or pull requests

9 participants