# Classifer based on GTDB having issues with scikit-learn versions

**URL:** https://forum.qiime2.org/t/classifer-based-on-gtdb-having-issues-with-scikit-learn-versions/30127
**Category:** User Support
**Tags:** feature-classifier, gtdb
**Created:** [May 6, 2024, 10:07pm UTC](https://forum.qiime2.org/t/classifer-based-on-gtdb-having-issues-with-scikit-learn-versions/30127 "2024-05-06T22:07:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![m\_s](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@m\_s](https://forum.qiime2.org/u/m_s)
#### Post date: [May 6, 2024, 10:07pm UTC](https://forum.qiime2.org/t/classifer-based-on-gtdb-having-issues-with-scikit-learn-versions/30127/1 "2024-05-06T22:07:44Z")

</div>

I used similar code to the code posted here for get-gtdb-data and then getting a feature calssifer:

> [@GTDB files for Taxonomy build](https://forum.qiime2.org/t/gtdb-files-for-taxonomy-build/23106/2):
>
> Hi @biojack, There are indeed a variety of files to use... Part of the issue is that many microbial taxa [contain multiple copies of the 16S rRNA gene](https://doi.org/10.1128/AEM.02953-09). These copies can be quite different from one another too! From what I gather the all files contain all of the copies of the 16S rRNA gene from a given genome. If you read the [File Descriptions](https://data.gtdb.ecogenomic.org/releases/release202/202.0/FILE_DESCRIPTIONS), you'll see that they curate the rep files differently than the all files based on what they include / exclude. Often researchers will simply increment th…

I am getting an error that I don't understand. I ran the code before updating my Mac OS last week to Sonoma 14.4.1, and it worked fine, but now it no longer works to run the classifer. It seems to have something to do with differing versions of scikit-learn, but it's not clear why the output of get-gtdb-data would clash with fit-classifier-naive-bayes.

If I use the classifer I generated without issue last week from gtdb (same code run), I cannot run the next step, classify-sklearn (code below at the bottom). For this code, the input files were generated a long time ago, and there might be differences scikit-learn - though, again, this code worked fine with two datasets last week that were generated around that same time.

Any ideas?

I am running QIIME 2024.2 amplicon in a conda environment.

qiime rescript get-gtdb-data   
--p-version '214.1'   
--o-gtdb-taxonomy gtdb-214\_1-taxonomy.qza   
--o-gtdb-sequences gtdb-214\_1-seqs.qza

qiime feature-classifier fit-classifier-naive-bayes   
--i-reference-reads gtdb-214\_1-seqs.qza   
--i-reference-taxonomy gtdb-214\_1-taxonomy.qza   
--o-classifier gtdb-214\_1\_classifier.qza   
--verbose

/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2\_feature\_classifier/classifier.py:104: UserWarning: The TaxonomicClassifier artifact that results from this method was trained using scikit-learn version 1.3.2. It cannot be used with other versions of scikit-learn. (While the classifier may complete successfully, the results will be unreliable.)  
warnings.warn(warning, UserWarning)  
Traceback (most recent call last):  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2cli/commands.py", line 520, in **call**  
results = self.\_execute\_action(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2cli/commands.py", line 581, in \_execute\_action  
results = action(\*\*arguments)  
File "", line 2, in fit\_classifier\_naive\_bayes  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/sdk/action.py", line 342, in bound\_callable  
outputs = self._callable\_executor_(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/sdk/action.py", line 566, in _callable\_executor_  
output\_views = self.\_callable(\*\*view\_args)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2\_feature\_classifier/classifier.py", line 339, in generic\_fitter  
pipeline = fit\_pipeline(reference\_reads, reference\_taxonomy,  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2\_feature\_classifier/\_skl.py", line 76, in fit\_pipeline  
pipeline.fit(X, y)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/base.py", line 1152, in wrapper  
return fit\_method(estimator, \*args, \*\*kwargs)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/pipeline.py", line 423, in fit  
Xt = self.\_fit(X, y, \*\*fit\_params\_steps)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/pipeline.py", line 377, in \_fit  
X, fitted\_transformer = fit\_transform\_one\_cached(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/joblib/memory.py", line 353, in **call**  
return self.func(\*args, \*\*kwargs)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/pipeline.py", line 957, in \_fit\_transform\_one  
res = transformer.fit\_transform(X, y, \*\*fit\_params)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/feature\_extraction/text.py", line 907, in fit\_transform  
return self.fit(X, y).transform(X)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/base.py", line 1145, in wrapper  
estimator.\_validate\_params()  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/base.py", line 638, in \_validate\_params  
validate\_parameter\_constraints(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/sklearn/utils/\_param\_validation.py", line 96, in validate\_parameter\_constraints  
raise InvalidParameterError(  
sklearn.utils.\_param\_validation.InvalidParameterError: The 'ngram\_range' parameter of HashingVectorizer must be an instance of 'tuple'. Got [7, 7] instead.

Plugin error from feature-classifier:

The 'ngram\_range' parameter of HashingVectorizer must be an instance of 'tuple'. Got [7, 7] instead.

See above for debug info

If I use the classifer I made before, it doesn't work now either.

qiime feature-classifier classify-sklearn   
--i-classifier gtdb-220\_classifier.qza   
--i-reads DRIFT2-K01-t225-rep-seqs-0523.qza   
--o-classification DRIFT2-K01-t225-gtdb-220\_taxonomy.qza \   
--verbose

Traceback (most recent call last):  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2cli/commands.py", line 520, in **call**  
results = self.\_execute\_action(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2cli/commands.py", line 581, in \_execute\_action  
results = action(\*\*arguments)  
File "", line 2, in classify\_sklearn  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/sdk/action.py", line 339, in bound\_callable  
self.signature.transform\_and\_add\_callable\_args\_to\_prov(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/core/type/signature.py", line 395, in transform\_and\_add\_callable\_args\_to\_prov  
self.\_transform\_and\_add\_input\_to\_prov(  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/core/type/signature.py", line 428, in \_transform\_and\_add\_input\_to\_prov  
transformed\_input = \_input.\_view(spec.view\_type, recorder)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/sdk/result.py", line 406, in \_view  
result = transformation(self.\_archiver.data\_dir)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/qiime2/core/transform.py", line 70, in transformation  
new\_view = transformer(view)  
File "/opt/anaconda3/envs/qiime2-amplicon-2024.2/lib/python3.8/site-packages/q2\_feature\_classifier/\_taxonomic\_classifier.py", line 59, in \_1  
raise ValueError('The scikit-learn version (%s) used to generate this'  
ValueError: The scikit-learn version (0.24.1) used to generate this artifact does not match the current version of scikit-learn installed (1.3.2). Please retrain your classifier for your current deployment to prevent data-corruption errors.

Plugin error from feature-classifier:

The scikit-learn version (0.24.1) used to generate this artifact does not match the current version of scikit-learn installed (1.3.2). Please retrain your classifier for your current deployment to prevent data-corruption errors.

See above for debug info.

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [May 7, 2024, 4:37am UTC](https://forum.qiime2.org/t/classifer-based-on-gtdb-having-issues-with-scikit-learn-versions/30127/2 "2024-05-07T04:37:58Z")

</div>

Hi @m_s ,

Both issues are related to the scikit-learn version that you have installed. It does not appear to be related to GTDB specifically, I think that is just a coincidence.

> [@m\_s](#):
>
> the current version of scikit-learn installed (1.3.2).

This is not the same version of scikit-learn that is installed as part of the amplicon distribution (0.24.1). So it seems like scikit-learn was updated in your environment some time in the past few weeks, and this has broken your environment. I suspect that someone pip-installed scikit-learn or another package (or perhaps this was somehow changed when you updated your Mac OS).

I recommend installing a fresh qiime2-amplicon-2024.2 environment and these errors should go away (both for training and using the classifiers).

Good luck!

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [June 7, 2024, 10:38am UTC](https://forum.qiime2.org/t/classifer-based-on-gtdb-having-issues-with-scikit-learn-versions/30127/3 "2024-06-07T10:38:22Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
