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

how can i solve this issue #4

Open
pawan-deligence opened this issue Oct 6, 2017 · 3 comments
Open

how can i solve this issue #4

pawan-deligence opened this issue Oct 6, 2017 · 3 comments

Comments

@pawan-deligence
Copy link

Performing PCA Transform.......
Traceback (most recent call last):
File "EmoDetect.py", line 114, in
Predict_Emotion(filename)
File "EmoDetect.py", line 63, in Predict_Emotion
pca_features=pca.transform(features)
File "/usr/local/lib/python2.7/dist-packages/sklearn/decomposition/base.py", line 128, in transform
X = check_array(X)
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 410, in check_array
"if it contains a single sample.".format(array))
ValueError: Expected 2D array, got 1D array instead:
array=[ 1.01314577 1.0087923 5.41773198 ..., 0.88240298 4.17091737
1.19806876].
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.

@andro-galexy
Copy link

reshape your feature vector to something like , [[ 1.01314577 1.0087923 5.41773198 ..., 0.88240298 4.17091737, 1.19806876]] instead of [ 1.01314577 1.0087923 5.41773198 ..., 0.88240298 4.17091737
1.19806876]

this can be done by reshaping the feature array:
pca_features=pca.transform(features)
pca_features = pca_features.reshape(1, -1)

@pawan-deligence
Copy link
Author

In this program you can also used dataset?

@michael1874888
Copy link

It should add a line to reshape the feature, not pca_features (before it)
so it should be:

features= numpy.asarray(features)
features = features.reshape(1, -1)

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

3 participants