qiime sample-classifier classify-samples error

I am trying to use the LinearSVC estimator (one of my friend said that it works better than Random forest for catergorical data with just yes and no, correct me if he is wrong)- same data works for random forest classifier -
running-
module load Anaconda/3-5.0.0.1
source activate qiime2-2020.6
command -
qiime sample-classifier classify-samples
–i-table CC_real_health_table.qza
–m-metadata-file CC_metadata.txt
–m-metadata-column real_health
–p-estimator LinearSVC
–p-random-state 108
–output-dir CC_machine_real_health_SVC
Error
most recent call last):
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2_sample_classifier/utilities.py”, line 683, in predict_probabilities
probs = pd.DataFrame(estimator.predict_proba(test_set),
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/sklearn/utils/metaestimators.py”, line 113, in get
getattr(delegate, self.attribute_name)
AttributeError: ‘LinearSVC’ object has no attribute ‘predict_proba’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/managers.py”, line 1678, in create_block_manager_from_blocks
make_block(values=blocks[0], placement=slice(0, len(axes[0])))
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/blocks.py”, line 3284, in make_block
return klass(values, ndim=ndim, placement=placement)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/blocks.py”, line 128, in init
“{mgr}”.format(val=len(self.values), mgr=len(self.mgr_locs))
ValueError: Wrong number of items passed 1, placement implies 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2cli/commands.py”, line 329, in call
results = action(**arguments)
File “”, line 2, in classify_samples
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 484, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2_sample_classifier/classify.py”, line 175, in classify_samples
X_test, sample_estimator, n_jobs)
File “”, line 2, in predict_classification
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 390, in callable_executor
output_views = self.callable(**view_args)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2_sample_classifier/classify.py”, line 292, in predict_classification
return predict_base(table, sample_estimator, n_jobs)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2_sample_classifier/classify.py”, line 282, in predict_base
probs = predict_probabilities(sample_estimator, feature_data, index)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/q2_sample_classifier/utilities.py”, line 688, in predict_probabilities
index=index, columns=estimator.classes
)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/frame.py”, line 440, in init
mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/construction.py”, line 213, in init_ndarray
return create_block_manager_from_blocks(block_values, [columns, index])
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/managers.py”, line 1688, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File “/software/hprc/Anaconda/3-5.0.0.1/envs/qiime2-2020.6/lib/python3.6/site-packages/pandas/core/internals/managers.py”, line 1719, in construction_error
“Shape of passed values is {0}, indices imply {1}”.format(passed, implied)
ValueError: Shape of passed values is (24, 1), indices imply (24, 2)

Thanks for the full error report, @Aravindh_Nagarajan!

It looks like q2-sample-classifier’s use of LinearSVC may have been broken by more recent releases of scikit-learn, and this is on our radar to fix. See this forum topic for some details and a suggested workaround at the end:

1 Like

@Nicholas_Bokulich - Thank you!