can not do csp.fit_transform() without label

I am usng MNE 0.23.4;
I am following this tutorial about CSP: mne.decoding.CSP — MNE 0.24.1 documentation
When I do: a=csp.fit_transform(epochs_data_train), I got complain like below:

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'

However, in the doc, it says ‘y’ is optional, could be set as y=None, as in mne.decoding.CSP — MNE 0.24.1 documentation . . Also in the paper titled ’ Common Spatial Pattern Method for Channel Selelction in Motor Imagery Based Brain-computer Interface’ by [Yijun Wang], they calculate CSP without using label.

Could you please help to clarify on this? Do I really need to feed my label to CSP because I am doing a regression task which I don’t have a label.

Hello @Long,

this is actually an API and a “documentation bug”. My understanding, after looking at the code, is that CSP.fit() (and, hence, CSP.fit_transform()) cannot work without a y with fewer than two classes. So you’ll have to specify a y parameter.

Best wishes,
Richard

I have opened an issue report at CSP.fit() requires y to work, however the parameter is optional in fit_transform() · Issue #10079 · mne-tools/mne-python · GitHub

doc is maybe not ideal but CSP is a supervised learning method so you need y with you call a “fit”

Alex

Dear all,
Thanks for clarifying on this.