A simple squared-error reformulation for ordinal classification

Christopher Beckham, Christopher J. PalarXiv 2016

Introduction: The Ordinal Challenge

In many machine learning applications, classification tasks involve labels with a natural, inherent ordering. For instance, in medical imaging, disease severity is often graded on an ordinal scale (e.g., Stage 0 to Stage 4). Standard classification approaches, such as those using cross-entropy loss, typically treat these labels as categorical and independent. This "one-hot" perspective is order-blind; it penalizes a prediction of Stage 4 for a Stage 0 case as severely as it would a prediction of Stage 1.

Conversely, regression models treat labels as continuous values, which respects the order but often fails to provide a useful probability distribution over the discrete classes. This paper introduces a middle ground: a squared-error reformulation that incorporates ordinal information while maintaining the probabilistic output of a classifier.

Methodology: The Squared-Error Reformulation

The authors propose a simple yet effective modification to the standard neural network architecture for classification. The approach centers on three key components:

  1. Softmax Hidden Layer: The final layer of the network is a softmax layer $f(x)$, which outputs a probability distribution over $k$ classes.
  2. The "Soft Argmax" Trick: To calculate a continuous "expected" class value, the authors introduce a weight vector $a = [0, 1, \dots, k-1]$. The predicted mean value is the dot product $a^T f(x)$.
  3. Squared-Error Loss: Instead of cross-entropy, the model minimizes the squared distance between the true class index $c$ and the predicted expectation: $L = (c - a^T f(x))^2$.
The architecture uses a softmax layer to generate a probability distribution, which is then mapped to an expected value via fixed weights $a_i$.

For inference, the model produces a discrete prediction by rounding the expected value $a^T f(x)$ to the nearest integer. This "conservative" prediction strategy focuses on minimizing large errors, which is particularly beneficial for metrics like the Quadratic Weighted Kappa (QWK).

Experimental Evaluation: Diabetic Retinopathy Detection

The proposed method, referred to as fix 'a', was evaluated using the Kaggle Diabetic Retinopathy (DR) dataset. This dataset consists of high-resolution fundus images where the task is to predict DR severity on a scale from 0 to 4. The dataset is characterized by significant labeling noise due to inter-observer variability among clinicians.

The authors compared "fix 'a'" against several baselines:

  • Cross-entropy: Standard categorical classification.
  • Cheng: An established ordinal regression technique using binary decompositions.
  • Learn 'a': A variant where the weights in vector $a$ are learned parameters, allowing the model to discover non-equidistant relationships between classes.

Key Results and Insights

The experimental results demonstrate that the squared-error reformulation significantly outperforms standard cross-entropy in ordinal tasks.

Validation loss (left) and Quadratic Weighted Kappa (right) comparison. The 'fix a' method shows superior stability and higher kappa scores compared to standard cross-entropy.

Superiority in Ordinal Metrics

As shown in the figures, the "fix 'a'" method consistently achieves a higher QWK than the cross-entropy baseline. Interestingly, the "learn 'a'" variant performed even better, suggesting that the perceived "distance" between disease stages is not necessarily uniform. For example, the transition from Stage 0 to 1 may be more distinct than from Stage 3 to 4.

Robustness to Label Noise

A key insight is that the squared-error approach is more "relaxed" than cross-entropy. While cross-entropy forces the model to concentrate all probability mass on a single correct label, the squared-error loss allows the model to spread mass across neighboring classes. This flexibility makes the model more robust to the inherent noise in medical labeling.

Generalization Paradox

Remarkably, the model trained with "fix 'a'" (squared error) actually achieved a lower validation cross-entropy loss than the model trained specifically to minimize cross-entropy. This suggests that the ordinal constraint acts as a powerful regularizer, leading to better overall generalization.

Conclusion

The simple squared-error reformulation provides a robust and effective way to handle ordinal classification. By bridging the gap between discrete classification and continuous regression, it leverages the strengths of both: the probabilistic output of the former and the order-awareness of the latter. While the method assumes equidistant classes by default, the "learn 'a'" variant offers a path toward modeling more complex class relationships. Future work could explore more sophisticated rounding schemes or direct metric optimization that preserves the quality of the underlying probability distributions.

Summary updated

BibTeX
@misc{beckham2016simple,
  author = {Christopher Beckham and Christopher J. Pal},
  title = {{A simple squared-error reformulation for ordinal classification}},
  year = {2016},
  eprint = {1612.00775},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1612.00775},
}
Figure