DEV Community

Cover image for The Loss Function Is a Business Decision, Not a Math Default
Vedant Narayan
Vedant Narayan

Posted on

The Loss Function Is a Business Decision, Not a Math Default

I used to think choosing a loss function was a technical detail. Something the framework handled for you.
It isn't. It's one of the most consequential decisions in your entire ML pipeline. And most teams never make it consciously.

Why MSE Fails for Classification

When you first learn machine learning, the loss function is Mean Squared Error. It makes sense for regression. But apply it to a churn prediction model and things break fast.
Consider this scenario. Your model predicts 2% churn probability. The account churns. CS never calls. A ₹40 lakh contract walks out the door.
MSE penalty for that failure? (1 - 0.02)² = 0.96.
Now consider a correct confident prediction — 90% churn, account churns. MSE penalty: (1 - 0.90)² = 0.01.
The ratio between catastrophic failure and correct confidence is barely 100x. That doesn't feel right. And it isn't.
There's also a structural problem. When you combine the logistic function with MSE, the loss surface goes non-convex. Multiple local minima. Flat regions where gradients vanish. Gradient descent gets lost and never finds the global optimum.

Why Cross-Entropy Won

Binary cross-entropy encodes a simple but powerful idea: being confidently wrong is a different category of failure.

Prediction   Actual   CE Loss
0.90         1        -log(0.90) = 0.10   <- minimal
0.50         1        -log(0.50) = 0.69   <- moderate
0.02         1        -log(0.02) = 3.91   <- catastrophic
Enter fullscreen mode Exit fullscreen mode

The penalty isn't linear or quadratic. It's logarithmic which means confident wrong predictions get hit exponentially harder.

Cross-entropy won for three principled reasons:

1. Mathematical harmony. Combine cross-entropy with the logistic function and you get a perfectly convex loss surface. One bowl. One global minimum. Gradient descent always finds it.

2. Maximum Likelihood Estimation. Minimizing cross-entropy is equivalent to maximizing the likelihood of your training data under the model, the most principled framework in statistics, formalized by R.A. Fisher in 1922.

3. Calibrated probabilities. A model trained with cross-entropy learns to produce probabilities that reflect reality. Its 0.8 prediction actually means roughly 80% of similar cases converted.

But Cross-Entropy Is Still Symmetric

Here's what most tutorials skip.

Cross-entropy treats false positives and false negatives equally. Your business almost certainly doesn't.

These are not the same cost. Yet your model punishes them identically by default.

These are not the same cost. Yet your model punishes them identically by default.

Two levers to fix this:

  • Lower the threshold from 0.5 to 0.2. Flag more accounts. Miss fewer churners. Accept more false alarms.

  • Use class weights to explicitly penalise false negatives harder during training.

The model defaults to 0.5 and balanced classes. If you haven't explicitly overridden that, the model made a business decision for you.

Did it make the right one?

Top comments (0)