Skip to content

CSP.fit() requires y to work, however the parameter is optional in fit_transform() #10079

Closed

Description

@hoechenberger

Reported on the forum:

https://mne.discourse.group/t/can-not-do-csp-fit-transform-without-label/4072

Calling CSP.fit_transform() without y (which is alright according to the API, which defaults y=None) yields the following exception:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/long/anaconda/envs/3.6/lib/python3.6/site-packages/mne/decoding/mixin.py", line 30, in fit_transform
    return self.fit(X, **fit_params).transform(X)
TypeError: fit() missing 1 required positional argument: 'y'

This is because the fit_transform() method inherited from TransformerMixin is not compatible with the fit method implemented in CSP.

Solution is to give CSP its very own fit_transform method that doesn't make y an optional parameter.

Activity

  1. added this to the 1.0 milestone on Dec 3, 2021
  2. changed the title [-]CSP.fit() required y to work, however the parameter is optional in the used mix-in class[/-] [+]CSP.fit() requires y to work, however the parameter is optional in fit_transform()[/+] on Dec 3, 2021
  3. larsoner commented on Dec 3, 2021

    @larsoner
    Member

    I think our typical solution is just to put y=None in the fit method, then never use it

  4. hoechenberger commented on Dec 3, 2021

    @hoechenberger
    MemberAuthor

    Since CSP is supervised, it cannot work without y.

    I'll propose a fix shortly.

  5. self-assigned this
    on Dec 3, 2021
  6. added a commit that references this issue on Dec 3, 2021
    3b32ef2
  7. added a commit that references this issue on Dec 3, 2021
    c1cbc78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions