# distinction between classify-samples and classify-samples-ncv

**URL:** <https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925>\
**Category:** User Support\
**Created:** [August 3, 2020, 4:08am UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925 "2020-08-03T04:08:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [August 3, 2020, 4:08am UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925/1 "2020-08-03T04:08:07Z")

</div>

I am struggling to appreciate the differences 🧐: between outputs from `qiime sample-classifier classify-samples` and `qiime sample-classifier classify-samples-ncv`. Both produce a number of similarly named outputs like `feature_importance.qza` and `predictions.qza`. However, the values of the `feature_importance.qza` artifact vary when the same input table/metadata are input.

From what I can tell in the descriptions in the [classify-samples-ncv documentation](https://docs.qiime2.org/2020.6/plugins/available/sample-classifier/classify-samples-ncv/?highlight=classify%20samples), the output of the `feature_importance.qza` provides a (relative) estimate of classification importance (accuracy?) each individual sequence feature contributes...

> Outputs predicted  
> values for each input sample, and relative importance of each feature for  
> model accuracy.

In the case of [classify-samples documentation](https://docs.qiime2.org/2020.6/plugins/available/sample-classifier/classify-samples/?highlight=classify%20samples), I also generate a `feature_importance.qza` file, and the description for this file seems to be the same as with the `classify-samples-ncv` output:

> --o-feature-importance ARTIFACT FeatureData[Importance]  
> Importance of each input feature to model accuracy.

Yet something must be different, as I noticed that the particular value for a given feature varies between the two `qiime sample-classifier` operations. For example, I ran an experiment that collected samples at different locations and different time points. The `classify-samples-ncv` output `feature_importance.qza` file for **location** results in 35 features contributing towards _half_ of the (cumulative) overall classifier importance. The same file with `classify-samples` using **location** metadata requires only 17 features to gather half of the overall classifier importance. Why the difference?

Thanks for any help you can offer distinguishing these two programs and their respective outputs!

---

<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:** [August 3, 2020, 5:06am UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925/2 "2020-08-03T05:06:30Z")

</div>

> [@devonorourke](#):
>
> The `classify-samples-ncv` output `feature_importance.qza` file for **location** results in 35 features contributing towards _half_ of the (cumulative) overall classifier importance. The same file with `classify-samples` using **location** metadata requires only 17 features to gather half of the overall classifier importance. Why the difference?

Different models, different training data.

NCV is training/testing N times over (where N = the number of cross-validations performed), and then averaging importance scores across each fold.

classify-samples is only training on a portion of the samples (since the remaining samples are held back as a test set). Hence, the training data look substantially different from NCV and may yield quite different results.

The model performance and feature importances will depend quite strongly on the training data, so it is not very surprising that these pipelines yield different importance scores (hopefully the top features should appear in both lists, if sample size is high enough — if not, it could be due to small sample size, noisy data, etc).

I hope that helps clarify!

---

<div class="post-metadata">

**Author:** ![devonorourke](https://forum.qiime2.org/user_avatar/forum.qiime2.org/devonorourke/32/3110_2.png) [@devonorourke](https://forum.qiime2.org/u/devonorourke)\
**Post date:** [August 3, 2020, 10:15am UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925/3 "2020-08-03T10:15:37Z")

</div>

Thanks. When seeking to resolve which particy features are important, would the `ncv` method be preferable?

What I'm still unclear about is the motivation in using each technique, so I think I need to read more on how these models work - staring at [this documentation](https://scikit-learn.org/stable/modules/ensemble.html#feature-importance-evaluation) is probably the start. Nevertheless, it seems like both `classify-samples` and `classify-samples-ncv` use a lot of the same terms, so differentiating their actions to understand why you'd use one over another still is giving me troubles 😕 .

As @Nicholas_Bokulich describes above, one difference seems to be how many times a feature might be evaluated for it's relative importance in training a model. With NCV, you're going to have _all_ features assessed for feature importance at least one time (or more, depending on how many folds, correct?). With `classify-samples`, is the difference relative to NCV that your training set is **_never_** tested for importance (that is, just those in the _testing_ set are?)?

Ideally, it would be great if someone could share an example of how they used both `classify-samples` and `classify-samplee-ncv` in action. Why would you use one over another? Can you use both to tease apart different aspects of your data?

Thanks again

---

<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:** [August 3, 2020, 1:53pm UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925/4 "2020-08-03T13:53:50Z")

</div>

> [@devonorourke](#):
>
> When seeking to resolve which particy features are important, would the `ncv` method be preferable?

In my opinion NCV is generally better, since it is training and testing across multiple iterations so gives a sense of variance in accuracy, as well as predictions for all samples.

> [@devonorourke](#):
>
> Nevertheless, it seems like both `classify-samples` and `classify-samples-ncv` use a lot of the same terms

Yes, because indeed these are using the same methods but different training/testing schemes.

> [@devonorourke](#):
>
> one difference seems to be how many times a feature might be evaluated for it’s relative importance in training a model

Not exactly — it's which samples are included in training, and how many times training occurs. This could indeed be a matter of which features are tested, but not necessarily.

> [@devonorourke](#):
>
> With `classify-samples` , is the difference relative to NCV that your training set is _ **never** _ tested for importance (that is, just those in the _testing_ set are?)?

No — importance is determined on the training set, so the difference is that importance is determined on only some of the samples and only once (whereas for NCV importance is averaged across each iteration).

> [@devonorourke](#):
>
> Why would you use one over another?

classify-samples is a complete pipeline and easier to use. It also outputs a trained classifier that can be re-used to predict other samples (NCV does not, since it trains K classifiers!). The motivations for NCV I mentioned above.

> [@devonorourke](#):
>
> Can you use both to tease apart different aspects of your data?

Both are perfectly valid to use, so it just depends on which is more suited to your use case... and the type of training/testing scheme you want to use.

---

<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:** [September 3, 2020, 7:53pm UTC](https://forum.qiime2.org/t/distinction-between-classify-samples-and-classify-samples-ncv/15925/5 "2020-09-03T19:53:53Z")

</div>

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