BinPro / CONCOCT

Clustering cONtigs with COverage and ComposiTion
Other
119 stars 48 forks source link

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

Open Rahimlou opened 1 year ago

Rahimlou commented 1 year ago

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 commented 1 year ago

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

maddne commented 1 year ago

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 commented 1 year ago

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

jpalmer37 commented 1 year ago

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 https://github.com/BinPro/CONCOCT/issues/321#issuecomment-1373775878

timeresistance1996 commented 1 year ago

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 commented 1 year ago

thanks, worked for me :)

marsfro commented 1 year ago

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

YeGuoZJU commented 1 year ago

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 commented 11 months ago

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!!!! :))