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

Feature names are only supported if all input features have string names #322

Open
Rahimlou opened this issue Dec 25, 2022 · 9 comments
Open

Comments

@Rahimlou
Copy link

Hello,

I receive the following error running concoct. I can't understand which file is problematic and how should I solve it.

TypeError: Feature names are only supported if all input features have string names, but your input has ['int', 'str'] as feature name / column name types. If you want feature names to be stored and validated, you must convert them all to strings, by using X.columns = X.columns.astype(str) for example. Otherwise you can remove feature / column names from your input data, or convert them all to a non-string data type.

@jpalmer37
Copy link

Receiving the same error. Can't seem to debug it. Would appreciate someone looking at this.

@maddne
Copy link

maddne commented Jan 16, 2023

Hi, I was able to workaround the issue by opening the validation.py file. In my case (concoct installed with conda) the file was in miniconda3/envs/concoct/lib/python3.10/site-packages/sklearn/utils/validation.py.
on line 1885 I changed the following:
feature_names = np.asarray(X.columns, dtype=object) to
feature_names = np.asarray(X.columns.astype(str), dtype=object)
The value error that you pasted said to do that in such case. It worked, got another error, but it is not connected to this one. Hope it helps!

@timeresistance1996
Copy link

I got the same error too. Have you fixed this problem?

@jpalmer37
Copy link

jpalmer37 commented Jan 18, 2023

Thanks @maddne! Seems like a promising step towards fixing it. If you or @timeresistance1996 are still encountering errors and need a quick solution, vinisalazar's custom conda environment worked for me with no errors. Here's a link to it #321 (comment)

@timeresistance1996
Copy link

Thank you so much! @jpalmer37 I have create a new conda env with #321mentioned, but run with a new error,which is,

/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/sklearn/utils/validation.py:1858: FutureWarning: Feature names only support names that are all strings. Got feature names with dtypes: ['int', 'str']. An error will be raised in 1.2.
warnings.warn(
Traceback (most recent call last):
File "/root/anaconda3/envs/concoct_env/bin/concoct", line 90, in
results = main(args)
File "/root/anaconda3/envs/concoct_env/bin/concoct", line 37, in main
transform_filter, pca = perform_pca(
File "/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/concoct/transform.py", line 5, in perform_pca
pca_object = PCA(n_components=nc, random_state=seed).fit(d)
File "/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/sklearn/decomposition/_pca.py", line 408, in fit
self._fit(X)
File "/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/sklearn/decomposition/_pca.py", line 456, in _fit
X = self._validate_data(
File "/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/sklearn/base.py", line 577, in _validate_data
X = check_array(X, input_name="X", **check_params)
File "/root/anaconda3/envs/concoct_env/lib/python3.10/site-packages/sklearn/utils/validation.py", line 909, in check_array
raise ValueError(
ValueError: Found array with 0 sample(s) (shape=(0, 138)) while a minimum of 1 is required by PCA.

Have you ever got this error before?

@jpinus
Copy link

jpinus commented Feb 9, 2023

thanks, worked for me :)

@marsfro
Copy link

marsfro commented Feb 9, 2023

I solved it by installing scikit-learn inside concoct_env
conda install -c intel scikit-learn

@YeGuoZJU
Copy link

YeGuoZJU commented Mar 2, 2023

Hi, I was able to workaround the issue by opening the validation.py file. In my case (concoct installed with conda) the file was in miniconda3/envs/concoct/lib/python3.10/site-packages/sklearn/utils/validation.py.
on line 1885 I changed the following:
feature_names = np.asarray(X.columns, dtype=object) to
feature_names = np.asarray(X.columns.astype(str), dtype=object)
The value error that you pasted said to do that in such case. It worked, got another error, but it is not connected to this one. Hope it helps!

thanks, I have fixed this error by using this way

@saras224
Copy link

Hi, I was able to workaround the issue by opening the validation.py file. In my case (concoct installed with conda) the file was in miniconda3/envs/concoct/lib/python3.10/site-packages/sklearn/utils/validation.py.
on line 1885 I changed the following:
feature_names = np.asarray(X.columns, dtype=object) to
feature_names = np.asarray(X.columns.astype(str), dtype=object)
The value error that you pasted said to do that in such case. It worked, got another error, but it is not connected to this one. Hope it helps!

thanks, I have fixed this error by using this way

Worked for me too!!! thanks for posting this up!!!! :))

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

8 participants