1
$\begingroup$

I recently had a discussion about machine learning. They said that they had problems with "accuracy" of the classifier, as far as I understood they used SVM. To solve the problem, they then switched the class label. The classifier has two classes, class A was labeled with 0 while class B was labeled with 1, so after the switch class A would be 1 and class B 0. But they would not change the definition, that samples with label 1 are "positive" and label 0 corresponds to a "negative" result.

They stated, that this switch alone increased the "accuracy" of the classifier. I write "accuracy", as I'm not sure if they actually meant the metric.

I do not see a reason why switching the class label should have any influence on the classifier. All you should see is, that the confusion matrix flips around, as you changed somehow the definition of "positive" and "negative" classes. Hence, also the metrices like precision and recall change, but the accuracy should stay the same.

But maybe I'm missing something here. Are there any classifiers which will have different results depending on the labeling of the classes?

$\endgroup$

2 Answers 2

4
$\begingroup$

It should have zero influence.

If your classifier (or its results) depend on whether you label your instances "0" and "1" versus "TRUE" and "FALSE" versus "vanilla" versus "chocolate", then something is very wrong. It may be that they inadvertently included the label as a feature, which defeats the purpose.

$\endgroup$
1
  • $\begingroup$ Thanks for the clarification. no, I really hope that they did not use the label as a feature.. $\endgroup$
    – reox
    Commented Jul 11, 2019 at 12:31
4
$\begingroup$

The evaluation metric may in fact be dependent on the labels, especially for imbalanced data.

For imbalanced data, the accuracy is typically a misleading metric, since the common interpretation is that 1 is ideal and 0 is bad. However, given that the majority class may already make up 99% of the data, a simple model predicting always the majority class will have an accuracy of 99%. It is true though, as you already stated, that the accuracy is independent from the labels.

However, my guess it that they were faced with an imbalanced data set and thus were talking of a different metric that aims to put more importance on the minority class and it's classification.

Short Reminder: When dealing with (binary) classification data, we typically use the confusion matrix to summarize our results:

Confusion Matrix
enter image description here

One such metric which addresses imbalanced data is recall, also referred to as sensitivity or True Positive Rate (TPR). It aims to summarize how well classification works on the Positive-class. It is defined as follows $$ \text{Recall} = \frac {\text{True Positives (i.e., classified Positive while being Positive)}} {\text{Positives (i.e., number of samples that have a Positive label assigned)}} $$ Clearly, recall is dependent on the labels, or more concretely on the choice which label corresponds to Positive. As stated earlier, in imbalanced data, we aim to put more importance on the minority class, thus one should use the minority class as Positive.

Let us close with an example to get a better understanding of what happens when labels are switched. For completeness, I also add the precision metric which aims to summarize how well positive identifications are, see this.

Correct Definition (Positive = Minority Class) Misleading Definition (Positive = Majority Class)
enter image description here enter image description here
$\text{Recall}=\frac {5.000}{5.000 + 4.000} \approx 0.56 $ $\text{Recall} = \frac {50.000} {50.000 + 500} \approx 0.99 $
$\text{Precision}=\frac {5.000}{5.000 + 500} \approx 0.91 $ $\text{Precision} = \frac {50.000} {50.000 + 4.000} \approx 0.93 $
$\endgroup$
3
  • 2
    $\begingroup$ This is a big problem when people use F-scores, combining precision and recall, to evaluate models. See this thread. (+1) $\endgroup$
    – EdM
    Commented Mar 10, 2022 at 17:20
  • $\begingroup$ On the other hand, if they would report both precision and recall (I would argue that giving only one of them is useless), you would see that after the label change, also precision and recall are changed. It is an interesting point though, to use the minority label as the positive outcome! $\endgroup$
    – reox
    Commented Mar 11, 2022 at 17:29
  • $\begingroup$ I added the precision metric for the example highlighting that both measures are overly optimistic when using Positive as the majority class. $\endgroup$
    – borea17
    Commented Mar 14, 2022 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.