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

[Bug]: spectrochempy.PLSRegression.predict() - not enough values to unpack (expected 2, got 1) #762

Open
sschusser opened this issue May 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@sschusser
Copy link

What happened?

I trained PLSRegression with IR spectra. The loadings look as expected. Unfortunately, runnding predict() results in the error
"ValueError: not enough values to unpack (expected 2, got 1)"

`File ~\Programme (portabel)\WPy64-31090\python-3.10.9.amd64\lib\site-packages\spectrochempy\utils\decorators.py:376, in _set_output.call(self, obj, *args, **kwargs)
374 X_transf.title = self.title
375 # make coordset
--> 376 M, N = X.shape
378 if X_transf.shape == X.shape and self.typex is None and self.typey is None:
379 X_transf.dims = X.dims

ValueError: not enough values to unpack (expected 2, got 1)`

What did you expect to happen?

Getting the predictes result.

Minimal Complete Verifiable Example

No response

Relevant log output

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None
python: 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('en_US', 'ISO8859-1')

-- dev installation --

FileNotFoundError: [Errno 2] No such file or directory: 'C:\XXXXXXXXXXXXXXX\lib\site-packages\requirements\requirements_dev.txt'

@sschusser sschusser added the bug Something isn't working label May 16, 2024
@atravert
Copy link
Collaborator

Hello,

Thank you very much for your message. It looks like it is related to the dims attribute of your dataset which corresponds to the names of the dimensions of the NDDataset, usually y and x

Can you check ?, e.g.:

>>> X.dims
['y', 'x'] 

if a single name ['y'], or no name is returned, then it is probably the origin of the error -- you will find more informations here on the dimensions and coordinates:
https://www.spectrochempy.fr/latest/userguide/objects/dataset/dataset.html#

Of course let us know whether this solves your problem.

Thanks,

@sschusser
Copy link
Author

sschusser commented May 22, 2024

I modified my code and programmed PLS Regression by hand from sklearn.cross_decomposition. This works fine.

Checking the dims got me

>>> spectra.dims
['y', 'x']

So, no abnormality in dimensions.

@atravert
Copy link
Collaborator

Thank you for your reply. Can you post or email me (arnaud.travert at unicaen.fr) the X and Y datasets with which ou are working -- or minimum sample datasets ? With this in hand I should be able to debug spectrochempy.

If you can't, yes the direct use of sklearn is indeed the solution !

Best,
Arnaud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants