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 in OPLSValidator #8

Open
juenhint opened this issue Nov 11, 2022 · 1 comment
Open

Bug in OPLSValidator #8

juenhint opened this issue Nov 11, 2022 · 1 comment

Comments

@juenhint
Copy link

juenhint commented Nov 11, 2022

The validator scripts are not working on any datasets, seems to be an issue with the fit method and the subsequent LabelBinarizer call. This is the error when running the example code:

TypeError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19292/3997691689.py in <module>
     10 X = df[[c for c in df.columns if c!='classification']]
     11 
---> 12 validator = OPLSValidator(k=-1).fit(X, target)
     13 
     14 Z = validator.opls_.transform(X)

C:\devel\anaconda3\lib\site-packages\pyopls\validation.py in fit(self, X, y, n_components, cv, pos_label, random_state, n_jobs, verbose, pre_dispatch)
    452 
    453         X = check_array(X, dtype=float, copy=True)
--> 454         y = self._check_target(y, pos_label)
    455 
    456         if not n_components:

C:\devel\anaconda3\lib\site-packages\pyopls\validation.py in _check_target(self, y, pos_label)
    223                              'Try binarizing with sklearn.preprocessing.LabelBinarizer.')
    224         if self.is_discrimination(y):
--> 225             y = self._process_binary_target(y, pos_label)
    226         else:
    227             self.binarizer_ = None

C:\devel\anaconda3\lib\site-packages\pyopls\validation.py in _process_binary_target(self, y, pos_label)
    211 
    212     def _process_binary_target(self, y, pos_label=None):
--> 213         self.binarizer_ = LabelBinarizer(-1, 1)
    214         self.binarizer_.fit(y)
    215         if pos_label is not None and self.binarizer_.transform([pos_label])[0] == -1:

TypeError: __init__() takes 1 positional argument but 3 were give
```n
@mguinto
Copy link

mguinto commented May 8, 2023

Hello, juenhint (and DPFoose)!

Would just like to ask about this as well.
Corroborating what's already been described above,
this is the error that shows up for me, even with the default wine dataset:

 File ~/.spyder-py3/untitled13.py:20 in <module>
    validator = OPLSValidator(k=5).fit(X, target)

  File ~/.local/lib/python3.8/site-packages/pyopls/validation.py:454 in fit
    y = self._check_target(y, pos_label)

  File ~/.local/lib/python3.8/site-packages/pyopls/validation.py:225 in _check_target
    y = self._process_binary_target(y, pos_label)

  File ~/.local/lib/python3.8/site-packages/pyopls/validation.py:213 in _process_binary_target
    self.binarizer_ = LabelBinarizer(-1, 1)

TypeError: __init__() takes 1 positional argument but 3 were given

Thank you very much!!

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

2 participants