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/", line 30, in fit_transform
    return, **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 (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,

I have opened an issue report at 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”


Dear all,
Thanks for clarifying on this.