The Trap of Optimizing the Wrong Metric
A model can climb its leaderboard score every week and still fail the task it was built for. The problem is rarely the algorithm; it is what you told it to chase.
Why the metric quietly runs the show
Every model is shaped by whatever number you ask it to minimise or maximise. That number is not a neutral scoreboard sitting outside the system; it is the objective the whole pipeline bends towards, from architecture choices to hyperparameter tuning to the point at which you decide a model is good enough to ship. If the metric only loosely resembles the thing you actually care about, you can spend months improving a system that is, by the measure that matters, going nowhere.
This is not a hypothetical worry about sloppy practitioners. It happens to careful people because metrics are proxies, and proxies drift away from the target the moment the data or the deployment context changes. A metric that was a faithful stand-in for success during development can become actively misleading in production, and the model will happily exploit that gap because nothing in the training process tells it not to.
The insidious part is that a wrong metric usually still produces a number that goes up. Loss decreases, accuracy climbs, the validation curve looks healthy. Everything about the workflow feels like progress. The trap is precisely that there is no obvious signal telling you that the progress is hollow; you only find out when the model meets the real world, or a more careful audit, and behaves nothing like the graphs promised.
A worked example: the accuracy trap under imbalance
Take a classifier built to flag a rare but important event, say something that occurs in one in every two hundred cases. That is a 0.5 percent positive rate. A model that simply predicts the negative class every single time will score 99.5 percent accuracy. It will look, on paper, better than almost anything a data scientist could realistically build, while doing precisely nothing useful. It never once identifies the event it was built to detect.
Now suppose a real model is trained and reaches 99.6 percent accuracy, a genuine improvement over the naive baseline by the metric everyone is watching. It would be easy to declare success. But dig into what changed: perhaps it now finds five of the two hundred true events, at the cost of ten false alarms elsewhere. Accuracy barely moved because the negative class dominates the count so heavily that anything happening in the tiny positive class is nearly invisible to that measure. The metric is technically correct and practically blind.
Switch instead to precision and recall on the positive class, or an F-measure that balances them, and the picture changes completely. Recall of five out of two hundred true events is 2.5 percent: an honest, uncomfortable number that accuracy had been hiding. That discomfort is the point. It tells you where the model genuinely stands relative to the task, rather than relative to a scoreboard that rewards ignoring the problem entirely.
The lesson generalises well beyond imbalanced classification. Any time a dominant, easy-to-get-right majority can swamp the signal from the minority outcome you actually care about, a single aggregate metric will systematically flatter models that do nothing interesting. The fix is not a cleverer model; it is choosing a metric that cannot be satisfied by the lazy answer.

It is not only imbalance: proxies drift everywhere
The same trap shows up in less obviously skewed settings. A recommendation system optimised purely for click-through rate will learn to favour sensational or misleading content, because clicks are cheap to generate and do not require the content to be genuinely useful. A forecasting model optimised purely for mean squared error will learn to predict the average outcome whenever it is unsure, because large errors are punished quadratically and playing it safe minimises expected penalty, even if that means the model is useless at flagging the rare extreme events users actually need warning about.
Leaderboard-style benchmarks carry a subtler version of the same risk. A held-out test set is only a good proxy for real-world performance if it was built with the same care as the deployment environment: no leakage between train and test splits, a distribution that resembles what the model will actually face, and a sample size large enough that the reported number is not noise dressed up as signal. Optimise hard enough against a leaky or narrow test set and you get a model that has, in effect, memorised the shortcut back to a high score rather than learned the underlying task.
None of this means metrics are useless or that you should distrust every number you see. It means a metric has to be chosen with the same rigour as the model itself, ideally before you have any results that might tempt you to defend whichever number happens to look good. Decide what failure actually costs, decide which errors matter more than others, and pick or construct a metric that reflects that, rather than reaching for whatever is easiest to compute or most familiar from a textbook.
A practical way out
Start by writing down, in plain language and before touching any code, what a good outcome actually looks like for the people or systems relying on the model. Then ask whether your candidate metric would give a high score to an obviously bad or lazy solution, the equivalent of the always-predict-negative classifier. If it would, that metric is not ready to be trusted as your main target, no matter how standard it is in the literature.
Use more than one metric during development, deliberately including ones that disagree with each other under different conditions, such as pairing precision with recall, or accuracy with a per-class breakdown. Disagreement between metrics is useful information; it tells you where the model's behaviour is being hidden by whichever single number you might otherwise have reported.
Finally, keep revisiting the choice as the project evolves. A metric that was appropriate at the prototype stage may need retiring once the model reaches production and the cost of each type of error becomes clearer. Treat the metric itself as a modelling decision, one that deserves documentation, justification, and periodic review, rather than a fixed backdrop you set once and forget. The model will always find the shortest path to whatever number you give it; your job is to make sure that path also leads somewhere worth going.
