Optimizing F-Measures by Cost-Sensitive Classification

Shameem Puthiya Parambath, Nicolas Usunier, Yves Grandvalet

The Challenge of F-Measures

In machine learning, we frequently rely on the F-measure (the harmonic mean of precision and recall) to evaluate models, particularly when dealing with imbalanced datasets where standard accuracy is misleading. However, F-measures present a mathematical challenge: they are non-linear ratios. This means they cannot be optimized using standard empirical risk minimization, which typically minimizes a linear sum of errors.

The conventional workaround is a two-step process:

  1. Train a model to output scores or probabilities.
  2. Pick a threshold post-hoc to maximize the F-measure on a validation set.

The authors of this paper argue that this approach is fundamentally flawed for many real-world scenarios. It assumes the model can accurately estimate probabilities across the entire distribution—an "asymptotic" assumption that often fails when using restricted model classes (like simple linear classifiers) or when training on limited data.

A Cost-Sensitive Solution

To bypass the need for perfect probability estimates, the authors introduce a rigorous theoretical framework that optimizes F-measures directly for any classifier type.

The core insight is that F-measures are pseudo-linear (specifically, fractional-linear). While the function itself is non-linear, its "level sets" (the sets of points where the F-measure is constant) are hyperplanes. Because of this structure, the authors prove a key reduction: for any optimal classifier for an F-measure, there exists a specific set of asymmetric costs (for false positives and false negatives) such that the classifier is also the optimal solution to a standard cost-sensitive classification problem.

The Meta-Algorithm

Since the "optimal" costs are unknown in advance, the authors propose a practical meta-algorithm:

  1. Discretize the cost space: The cost ratio is a single value between 0 and 1. Pick a set of candidate costs (e.g., $t \in \{0.1, 0.2, ... 0.9\}$).
  2. Solve the inner loop: For each candidate cost, train a standard cost-sensitive classifier (such as a weighted SVM or weighted Logistic Regression).
  3. Select the winner: Evaluate all resulting classifiers on a validation set using the target F-measure and select the best performer.

This approach provides a non-asymptotic guarantee, meaning it works reliably on finite datasets regardless of the underlying classifier chosen.

Decision boundaries before and after thresholding

Key Results and Performance

The authors evaluated their approach on four diverse datasets: Adult (binary), Letter (multiclass), News20 (multiclass text), and Siam (multilabel text).

Their experiments dismantled the "thresholding myth." While theoretical models suggest post-hoc thresholding is sufficient, cost-sensitive training on finite data consistently finds better decision boundaries that simple thresholding of a standard model cannot reach.

Performance comparison across datasets for baseline, thresholding (T), cost-sensitive (CS), and combined (CS&T) methods

As shown in the results table, the cost-sensitive approach yielded massive performance gains. On the News20 dataset, a standard SVM baseline achieved an $F_1$ score of 59.5%. By applying the cost-sensitive (CS) reduction, performance jumped to 81.7%.

Furthermore, the proposed method proved highly competitive with SVMperf (a specialized algorithm designed specifically for F-measure optimization), while offering much greater flexibility since it can wrap any cost-sensitive learner. Interestingly, the absolute best results were often achieved by combining cost-sensitive training with post-hoc thresholding (CS&T), yielding an $F_1$ of 82.4% on News20.

Limitations and Future Directions

While powerful, the method does have limitations:

  • Computational Cost: The "outer loop" requires training multiple classifiers. Though this can be mitigated with "warm-starts" (using the solution of one cost as the starting point for the next), it remains more expensive than training a single model.
  • Micro-F-measure Complexity: The reduction easily handles binary and macro-F-measures, but the multiclass micro-F-measure is mathematically more complex and was only explored under specific constraints.
  • Search Efficiency: The current algorithm uses a uniform discretization of the cost space. Future work could explore more efficient search techniques, such as bisection or coordinate descent, to find optimal costs faster.

Summary updated

BibTeX
@inproceedings{parambath2014optimizing,
  author = {Shameem Puthiya Parambath and Nicolas Usunier and Yves Grandvalet},
  title = {{Optimizing F-Measures by Cost-Sensitive Classification}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2014},
  url = {https://openreview.net/forum?id=ByZ8Adb_Zr},
}
Figure