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

Error with scikit-learn 1.2 : TypeError: Feature names #321

Open
nickp60 opened this issue Dec 10, 2022 · 9 comments
Open

Error with scikit-learn 1.2 : TypeError: Feature names #321

nickp60 opened this issue Dec 10, 2022 · 9 comments

Comments

@nickp60
Copy link

nickp60 commented Dec 10, 2022

Not sure if this has been noted before, but I tried to install CONCOCT and it pulled scikit-learn 1.2. When running, i got the following error:

Traceback (most recent call last):
  File "/opt/conda/bin/concoct", line 92, in <module>
    results = main(args)
  File "/opt/conda/bin/concoct", line 39, in main
    transform_filter, pca = perform_pca(
  File "/opt/conda/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 "/opt/conda/lib/python3.10/site-packages/sklearn/decomposition/_pca.py", line 435, in fit
    self._fit(X)
  File "/opt/conda/lib/python3.10/site-packages/sklearn/decomposition/_pca.py", line 485, in _fit
    X = self._validate_data(
  File "/opt/conda/lib/python3.10/site-packages/sklearn/base.py", line 518, in _validate_data
    self._check_feature_names(X, reset=reset)
  File "/opt/conda/lib/python3.10/site-packages/sklearn/base.py", line 385, in _check_feature_names
    feature_names_in = _get_feature_names(X)
  File "/opt/conda/lib/python3.10/site-packages/sklearn/utils/validation.py", line 1893, in _get_feature_names
    raise TypeError(
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.

This appears to be changed from a warning in version 1.2.

Replacing scikit-learn 1.2 with scikit-learn 1.1 resolved the issue for me.

@tanaes
Copy link

tanaes commented Dec 17, 2022

Thanks for this, I just encountered the problem as well.

@tamburinif
Copy link

tamburinif commented Dec 22, 2022

I'm running into this issue as well. I tried downgrading scikit-learn to 1.1 but this gives a warning:

OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.

@nickp60
Copy link
Author

nickp60 commented Dec 22, 2022

I haven't tested it fully but I think I resolved this? The dockerfile is here, the key I think is installing libopenblas with conda for a specific build created using OpenMP:
https://github.com/vdblab/dockerfiles/blob/main/metawrap/Dockerfile

@fallinwind
Copy link

same

@vinisalazar
Copy link

I tried both of these fixes (downgrading sklearn + using the libopenblas openmp build) and they worked. Perhaps it would be worth it to pin the version of scikit-learn as scikit-learn<=1.1,>=0.14.1 on the requirements file?

scikit-learn>=0.14.1

@fallinwind
Copy link

I tried both of these fixes (downgrading sklearn + using the libopenblas openmp build) and they worked. Perhaps it would be worth it to pin the version of scikit-learn as scikit-learn<=1.1,>=0.14.1 on the requirements file?

scikit-learn>=0.14.1

Hi Vini @vinisalazar , may I ask how to use the libopenblas openmp build ? anticipating your reply

@vinisalazar
Copy link

Hi @fallinwind, I'm installing concoct by creating a conda environment from a yaml file, here's how it looks like:

channels:
  - conda-forge
  - bioconda
dependencies:
  - concoct=1.1.0
  - libopenblas=*=openmp*
  - mkl
  - python>=3
  - samtools>=1.9
  - scikit-learn=1.1.*
variables:
  USE_OPENMP: 1

You can create the environment from such a file with the conda env create command.

Best,
V

@marsfro
Copy link

marsfro commented Feb 9, 2023

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

@99qaz
Copy link

99qaz commented Jul 21, 2023

我也遇到了这个问题。我尝试将 scikit-learn 降级到 1.1,但会发出警告:

OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.

Hello, I have encountered the same issue. Have you managed to resolve this problem?

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

7 participants