A step towards understanding why classification helps regression

Silvia L. Pintea, Yancong Lin, Jouke Dijkstra, Jan C. van GemertICCV 2023 · DOI

Abstract

In computer vision, adding a classification loss to regression tasks is a common empirical technique to improve performance. This paper investigates the underlying mechanisms of this phenomenon, demonstrating that classification primarily serves as a regularizer that mitigates the negative effects of data imbalance. By bridging the gap between imbalanced and balanced regression losses, classification helps models learn underlying functions more effectively when training samples are non-uniformly distributed.

Introduction

Regression models are designed to predict continuous values, such as depth or age, while classification models map inputs to discrete bins. Theoretically, regression targets provide more granular information than classification labels. Despite this, state-of-the-art models in tasks like depth estimation often perform better when a classification loss is included in the training objective. While previous hypotheses suggested that classification might handle noise or prevent over-smoothing, this research provides a rigorous testing framework to identify the specific conditions under which classification is beneficial.

Methodology: The Impact of Imbalance

The researchers utilized a controlled 1D environment featuring non-linear functions (sums of sine waves) to isolate key variables: noise, out-of-distribution data, and data sampling imbalance. By varying the sampling density, they created datasets ranging from uniform to severely imbalanced.

Figure 1: Synthetic 1D data with varying levels of sampling imbalance (Uniform, Mild, Moderate, Severe) and corresponding target distributions shown in the histograms below.

As shown in Figure 1, the "Severe" imbalance case concentrates training samples into a very narrow range of the target space. This setup allowed the authors to derive a mathematical relationship between the Negative Log-Likelihood (NLL) of imbalanced data and balanced data. They found that the discrepancy caused by imbalance can be effectively approximated by a standard cross-entropy classification loss, essentially allowing the classification task to act as a bridge that helps the model "ignore" sampling bias.

Key Results and Empirical Validation

The core finding of the study is that the benefit of classification is directly proportional to the degree of imbalance in the training set. In perfectly uniform datasets, adding a classification loss provides negligible improvement. However, as imbalance increases, the performance gap between pure regression and joint regression-classification grows significantly.

Figure 2: Performance comparison (MSE) between regression only (red) and regression with classification (green) across different imbalance levels. The gap in Mean Squared Error (MSE) widens as imbalance becomes more severe.

In the 1D experiments (Figure 2), the "Severe" imbalance scenario for clean data showed a substantial MSE gap of 0.123. This effect persisted even in the presence of noise. Interestingly, the number of classes used for the auxiliary task (ranging from $2^2$ to $2^{10}$) had a relatively stable impact, though the authors found that using histogram equalization to define class boundaries (ensuring each bin contains roughly the same number of samples) made the model less sensitive to hyperparameters.

Real-World Performance

The findings were validated on several real-world imbalanced datasets:

  • Age Estimation (IMDB-WIKI-DIR): Adding a 100-class classification loss improved the Mean Absolute Error (MAE) from 8.09 to 7.61.
  • Video Progress (Breakfast Dataset): Joint training consistently lowered the Root Mean Squared Error (RMSE) across test splits, for example, reducing it from 32.57% to 28.71%.

Conclusion

This research demystifies a common "trick" in deep learning by identifying data imbalance as the primary driver behind the success of joint regression-classification training. Regression losses like MSE penalize errors based on magnitude, which can pull a model too strongly toward over-represented samples. Classification, by treating all "wrong bin" predictions with a different penalty structure, provides the necessary resistance to this bias. The authors offer a simple rule of thumb for practitioners: "For a regression task, if the data sampling is imbalanced, then add a classification loss."

Summary updated

BibTeX
@inproceedings{pintea2023step,
  author = {Silvia L. Pintea and Yancong Lin and Jouke Dijkstra and Jan C. van Gemert},
  title = {{A step towards understanding why classification helps regression}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
  doi = {10.1109/iccv51070.2023.01828},
}
Figure