Quant Memo
Core

Class Imbalance in Financial Labels

The events worth predicting in markets — big moves, regime breaks, rare fills — are almost always the minority class, and a model trained naively on that imbalance learns to just predict the common outcome every time.

Prerequisites: The Confusion Matrix and Classification Metrics

Say you build a classifier to flag "large adverse move in the next hour," and in your training data that happens 2% of the time. A model that always predicts "no large move" is right 98% of the time — and completely useless, since it never once flags the event you actually built the model to catch. This is class imbalance: when one label vastly outnumbers the other, standard training and standard accuracy both quietly reward the model for ignoring the minority class, which in finance is usually the class you care about most.

Why finance is especially prone to this

Most interesting financial labels are rare by construction. Large drawdowns, triple-barrier profit-take hits, flash-crash events, stop-outs, order fills at the best price — these are minority events precisely because if they were common, the market would already have priced them away. A naive classifier minimizing overall error will drift toward always predicting the majority class, and a naive accuracy metric will happily confirm that this looks like a "97% accurate model" while its recall on the event that matters is zero. The fix isn't a single trick but a family of them: resample the training data (oversample the minority class or undersample the majority), reweight the loss function so misclassifying the rare class costs more, or move the decision threshold after training rather than leaving it at the default 0.5.

Worked example: reweighting versus resampling

A dataset has 9,800 "no large move" labels and 200 "large move" labels (a 49:1 imbalance). Two common fixes:

  • Class weighting: assign the minority class a loss weight of w=9800200=49w = \frac{9800}{200} = 49, so each large-move example counts 49× as much during training as each no-move example — roughly balancing their total influence on the loss without touching the data itself.
  • Random undersampling: randomly discard majority-class rows until the two classes are closer to balanced, e.g. keeping only 1,000 of the 9,800 no-move rows to leave a 5:1 ratio — cheaper to train on, but it throws away a lot of legitimate data and can hurt the model's read on the majority class.

Whichever approach is used, evaluation must also change: report precision, recall, and F1F_1 on the minority class specifically, not overall accuracy, since accuracy stays near 98% almost regardless of how badly the model handles the rare event.

raw data (49:1) after rebalancing no-move large move
Raw labels are dominated by the common outcome; reweighting or resampling brings the minority "large move" class enough influence during training that the model can actually learn to recognize it.

What this means in practice

Always check the class balance of a label before trusting any accuracy number, and always evaluate rare-event classifiers on recall and precision for the minority class, ideally alongside a precision-recall curve rather than an ROC curve, which can look deceptively good under heavy imbalance. Whatever rebalancing technique is used during training, keep the test set at its natural, un-rebalanced frequency — the point is to train a model that notices rare events, not to evaluate it on a world where they're artificially common.

When one label class vastly outnumbers the other, a model can achieve high accuracy by simply ignoring the minority class — which in finance is usually the rare, high-value event you built the model to catch. Fix it with class weighting, resampling, or threshold adjustment, and always evaluate with recall and precision on the minority class rather than overall accuracy.

Never rebalance the test set to match the training set's artificial balance — evaluate on data with the label's true, natural frequency, or your reported performance will overstate how the model behaves in production.

Related concepts

Practice in interviews

Further reading

  • de Prado, Advances in Financial Machine Learning, ch. 3
ShareTwitterLinkedIn