bustios / zeppelin-notebooks

Gallery of Apache Zeppelin notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in Feature Extraction step

Yash-Bolisetty opened this issue · comments

Hey Paul,
Amazing notebook about the motor imagery classification. I was trying to replicate this on my machine but I was running into some difficulties in the feature extractions step. I am getting all of the output to all the prior steps (eventhough it is taking quite some time to plot the previous graph), but i am running into the following error:
File "", line 1, in
File "", line 14, in create_fbcsp
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 618, in init
self._validate_transformers()
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 652, in _validate_transformers
self._validate_names(names)
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 75, in _validate_names
'{0!r}'.format(list(names)))
ValueError: Names provided are not unique: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe']
Traceback (most recent call last):
File "", line 1, in
NameError: name 'fbcsp' is not defined
Traceback (most recent call last):
File "", line 1, in
NameError: name 'X_train_feats' is not defined

I have tried to assess this error but I am at a dead end. Any help given would be appreciated.
Thanks you so much once again!!

Hi @Yash-Bolisetty ,

Thanks for reporting the problem. What version of sklearn are you using? It looks like your sklearn version does not accept repeated names for the transformers.

In the function create_fbcsp, try replacing:

for low in bands:
        pipeline_list.append(
            ("pipe", Pipeline([
                ("filter", BandPassFilter(low, low + band_width)),
                ("csp", CSP(n_components=n_csp_components))
            ]))
        )

by

for low in bands:
        pipeline_list.append(
            Pipeline([
                ("filter", BandPassFilter(low, low + band_width)),
                ("csp", CSP(n_components=n_csp_components))
            ])
        )

or give a different name for each Pipeline appended to pipeline_list.

Hey @bustios thanks for the quick reply. I am currently using sklearn version 0.18.1. I tried replacing the code you showed and was faced with this error:

Traceback (most recent call last):
File "", line 1, in
File "", line 14, in create_fbcsp
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 618, in init
self._validate_transformers()
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 649, in _validate_transformers
names, transformers = zip(*self.transformer_list)
TypeError: zip argument #1 must support iteration
Traceback (most recent call last):
File "", line 1, in
NameError: name 'fbcsp' is not defined
Traceback (most recent call last):
File "", line 1, in
NameError: name 'X_train_feats' is not defined

How should I attempt to fix this or should I just try a different version of sklearn?

@bustios If it would be easier, we could get in a google hangout call to discuss these issues or any further issues?

@bustios I also tried to make the names unique by adding some random number to each of the Pipelines but I got the same error I think:

Traceback (most recent call last):
File "", line 1, in
File "", line 14, in create_fbcsp
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 618, in init
self._validate_transformers()
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 652, in _validate_transformers
self._validate_names(names)
File "/Users/yashbolisetty/anaconda3/lib/python3.6/site-packages/sklearn/pipeline.py", line 75, in _validate_names
'{0!r}'.format(list(names)))
ValueError: Names provided are not unique: ['pipe6', 'pipe1', 'pipe4', 'pipe4', 'pipe6', 'pipe10', 'pipe6', 'pipe4', 'pipe4', 'pipe2', 'pipe7', 'pipe9']
Traceback (most recent call last):
File "", line 1, in
NameError: name 'fbcsp' is not defined
Traceback (most recent call last):
File "", line 1, in
NameError: name 'X_train_feats' is not defined

Once again, if there is a better way for communication and solving these issues, please feel free to mention them.

Thanks so much,

Yash Bolisetty

Hey Paul,
Any help for the errors above are appreciated! Wondering what Sklearn version you used as well?
Thanks,
Yash B

Hi @Yash-Bolisetty ,
sorry for the late response. I used sklearn version 0.17.1.
When you added random numbers to the names of the pipelines, the resulting names were not unique:

ValueError: Names provided are not unique: ['pipe6', 'pipe1', 'pipe4', 'pipe4', 'pipe6', 'pipe10', 'pipe6', 'pipe4', 'pipe4', 'pipe2', 'pipe7', 'pipe9']

that's why you still have the same error.

Yeah @bustios I had it figured out after looking at it for some time. Thanks anyways for the help!!!!