Concepts / Decision Boundaries in Classification

Decision Boundaries in Classification

A decision boundary is the separator between the regions of input space that a model assigns to different classes.

  • Programming

A Confident Model Is Not Automatically a Right Model

Suppose a classifier tells you it is very sure about a prediction. It is tempting to conclude that the prediction is probably right, and that the more certain the model sounds, the more you can trust it. This feels reasonable, but it quietly mixes two separate questions. The first question is what the model says about its own confidence. The second question is how often the model is actually correct when it says that. This article is about the gap between those two questions, and about the property that closes it.

Keep both questions in mind as you read. A classifier can produce a confidence number for every prediction, and that number may look authoritative. Whether the number deserves your trust is a separate matter, and the rest of this article shows how to tell the difference.

Tracing the Two Questions Behind a Confidence Score

Think of a model's confidence as a claim it makes about each prediction. The claim is stated as a number, such as 70%. The question you can actually check is what happened to the predictions that carried that claim. Did the predictions made with 70% confidence turn out right about 70% of the time? Or did they turn out right much more often, or much less often?

What do you think happens?

A model labels 100 different inputs as 'predicted with 70% certainty.' Roughly how many of those 100 predictions should be correct if the model is calibrated?

  • About 30

  • About 70

  • All 100

Reveal answer
Answer:

About 70

Calibration is a statement about a group of predictions that share the same stated confidence. If the model is calibrated, a prediction made with 70% certainty is correct about 70% of the time across such predictions, so roughly 70 of the 100 should be correct. Calibration says nothing about whether any single one of them is right.

What Calibration Requires

Definition

A model is calibrated when its reported uncertainty matches how correct it is: a prediction made with 70% certainty should be correct about 70% of the time across such predictions.

Rule

Read the formula in words. Among all the predictions where the model reports confidence p, the fraction that turn out correct should be p. The vertical bar means 'given that,' so the left side is the probability of being correct, given the stated confidence. The equation states that this probability equals the stated confidence itself. Notice that the claim applies to a group of predictions that share the same stated confidence, not to one prediction at a time.

Calibrated modelStated 70%Miscalibrated modelStated 70%Observed correct rateAbout 70%Observed correct rateNot near 70%should matchgap appears
If I group all predictions reported at 70% confidence, how does their actual correct rate compare to 70%, and where does a miscalibrated model's gap show up?

The diagram above is a generated illustration rather than a result from the source. It shows the two situations the definition distinguishes. In the calibrated case, the group of predictions stated at 70% is correct about 70% of the time. In the miscalibrated case, the same stated 70% is attached to a different observed rate, and that difference is the gap calibration is meant to rule out.

Reading Binary Probabilities to Find the Predicted Class

Classifiers that expose uncertainty estimates give a probability for each class. In a binary problem with two classes, those two probabilities add up to 1. Because they must sum to 1, exactly one class will be above 50% certainty, and that is the class the model predicts. The predicted class is therefore the one carrying the larger share of the probability.

Worked example

Finding the predicted class from two probabilities

A binary classifier returns the probability vector [0.3, 0.7] for one input, where the first entry is class 0 and the second entry is class 1. Which class does the model predict?

  1. 1
    Check the sum

    0.3 + 0.7 = 1, which matches the binary rule that the two class probabilities add up to 1.

  2. 2
    Find the value above 50%

    0.3 is below 0.5 and 0.7 is above 0.5. Exactly one class is above 50%.

  3. 3
    Map the position to the class

    The larger value sits in position 1, which corresponds to class 1.

Result

The predicted class is class 1, with a stated probability of 0.7.

Notice what this does and does not tell you. The 0.7 is the model's stated confidence in class 1. It identifies the predicted class, but whether 0.7 is calibrated is a separate question, answered only by checking how often predictions stated at 0.7 are actually correct.

Reading Multiclass Probability Vectors

The same reading strategy extends to problems with more than two classes. The source notes that the decision_function and predict_proba methods work in the multiclass setting, where there are more than two classes. It illustrates this on the Iris dataset, which is a three-class dataset. Both methods provide uncertainty estimates in both binary and multiclass settings, though they report those estimates in different forms.

For a multiclass probability output, each position in the vector corresponds to one class. To find the predicted class, locate the position holding the highest value, then read off the class that position maps to. The values below are generated for illustration and are not taken from the source.

Class 00.10Class 10.75Class 20.15
Given a list of probabilities for several classes, which position holds the highest value, and which class label does that position map to?

In the illustration, position 1 holds the highest value, 0.75, so the predicted class is Class 1. The values in the vector are a probability for each class, and the predicted class is the one with the largest share. The source does not spell out the multiclass version of the sum-to-one property, so do not assume a particular total from the binary case. Check the values the model actually returns.

Where the Decision Boundary Meets Uncertainty

A decision boundary is the separator between the regions of input space that a model assigns to different classes. Moving across the boundary changes which class is predicted. The probabilities the model reports also change as you move, and that change is where uncertainty lives.

The source describes a gradient boosting model whose decision boundary is shown alongside the predicted probabilities for class 1 over the same dataset. In that visualization the boundaries are much more well-defined, and the small regions where the model is uncertain are clearly visible. Those narrow uncertain bands are where the probability for class 1 sits near the middle, which means they lie close to the boundary between the two classes.

The source also notes that in its example the classifier is relatively certain for most points, so most points sit comfortably on one side of 50%. That overall picture tells you how the model behaves, but it does not by itself tell you whether the certainty is deserved. Whether the reported uncertainty reflects real uncertainty in the data depends on the model and its parameters.

Tracing a Calibration Check Step by Step

Calibration can be checked by following a sequence of steps that moves from individual predictions to a comparison at the group level. The diagram below traces that sequence. Each step follows from the definition: predictions are grouped by the confidence they report, and the observed correct fraction in each group is compared with the stated number.

Collect predictionsPredictions with knownoutcomesGroup by statedconfidenceAll predictions at 70%Count correct in eachgroupObserved correct fractionCompare with statedconfidenceDo they match?
At which step does a model's stated certainty stop matching how often it is actually right?

The divergence happens at the last step. A model can look certain at the first step, with every prediction reporting high confidence, and still fail the comparison. The stated certainty stops matching observed correctness exactly when the group's correct fraction differs from the number the model reported.

Model Complexity, Overfitting, and Certainty

The source ties the reliability of a model's uncertainty to its complexity, and it makes two claims that point in opposite directions. First, a model that is more overfitted tends to make more certain predictions, even if those predictions might be wrong. Second, a model with less complexity usually has more uncertainty in its predictions.

This matters for calibration because an overfitted model can look confident for the wrong reason. Its high certainty reflects how closely it has fit the training data, not necessarily how often it will be right on new inputs. Certainty alone therefore cannot be read as calibration. A calibrated model's stated confidence has to line up with how often it is correct, and an overfitted model can report high confidence while that alignment fails.

PropertySimpler model (less complex)Overfitted model (more complex)
Typical certainty of predictionsUsually shows more uncertaintyTends to make more certain predictions
Is high certainty a sign of being right?Certainty is less extreme, so it signals cautionNot on its own; predictions can be confidently wrong
What the certainty reflectsThe model's broader view of the dataHow closely the model has fit the training data
Calibration riskStated confidence must still be checked against outcomesStated confidence may fail to match how often it is correct

Complexity and certainty, as described by the source. The right-hand column is what the source warns about.

Mistakes Learners Make When Reading Confidence

  • Common mistake

    Treating a high confidence score as proof that a prediction is right

    What it looks like

    A model reports 95% for one input and the learner concludes that input is almost certainly correct.

    Why it fails

    Calibration is about groups of predictions sharing a stated confidence. One high-confidence prediction says nothing about whether the model's stated confidence matches correctness across many such predictions.

    Do this instead

    Ask how often predictions with that stated confidence are correct across a group, not whether this single prediction is right.

  • Common mistake

    Assuming predict_proba output is calibrated because of its name

    What it looks like

    A learner calls predict_proba and treats the returned numbers as true probabilities without checking them.

    Why it fails

    The source establishes that predict_proba provides uncertainty estimates, but providing an estimate does not by itself guarantee calibration.

    Do this instead

    Treat the output as an estimate and verify calibration separately, by comparing stated confidence to observed correct rates.

  • Common mistake

    Reading the predicted class from the wrong position

    What it looks like

    In the vector [0.3, 0.7], the learner picks class 0 because it is listed first.

    Why it fails

    The predicted class is the one carrying the larger share of the probability, not the first entry in the list.

    Do this instead

    Find the largest value first, then map its position to the class label.

  • Common mistake

    Reading a very confident model as a better model without checking complexity

    What it looks like

    A learner sees an overfitted model producing almost all predictions near 0 or 1 and concludes it is the most reliable model.

    Why it fails

    The source notes that overfitted models tend to make more certain predictions even when they are wrong, so high certainty alone does not establish reliability.

    Do this instead

    Check how the model's stated confidence matches its correct rate on data it was not fit to, and be cautious about extreme confidence from an overly complex model.

Practice: Predicted Classes and Calibration Checks

EASY

A binary classifier returns the probability vector [0.42, 0.58] for an input, where the first entry is class 0 and the second entry is class 1. Which class is predicted, and what does that tell you about the other class's probability?

Hints
  • The two probabilities add up to 1 in a binary problem.
  • Find which value is above 50%, then map its position to a class label.
  • The other class has the remaining share of the probability, which is 0.42 here.
MEDIUM

A model reports 70% confidence on 200 predictions. Using the definition of calibration, about how many of those predictions should be correct if the model is calibrated, and what observation would show the model is miscalibrated?

Hints
  • Calibration is a statement about a group of predictions that share the same stated confidence.
  • Multiply the group size by the stated confidence.
  • Compare the observed correct count to the expected count and ask how large the gap is.

Key Ideas from Decision Boundaries and Calibration

  1. 1
    A model is calibrated when its reported uncertainty matches how correct it is: predictions stated at 70% should be correct about 70% of the time across the group.
  2. 2
    In a binary problem the two class probabilities sum to 1, so exactly one class is above 50% and that class is the predicted one. In multiclass problems, the predicted class is the position with the highest value.
  3. 3
    Overfitted models tend to make more certain predictions even when they are wrong, so high certainty alone does not establish reliability.
  4. 4
    The decision_function and predict_proba methods provide uncertainty estimates in binary and multiclass settings, but providing an estimate does not by itself guarantee calibration.

Key Takeaways

  • A model is calibrated when its reported uncertainty matches how correct it is: predictions stated at 70% should be correct about 70% of the time across the group.
  • In a binary problem the two class probabilities sum to 1, so exactly one class is above 50% and that class is the predicted one.
  • Overfitted models tend to make more certain predictions even when they are wrong, so high certainty alone does not establish reliability.
  • Providing an uncertainty estimate, as decision_function and predict_proba do, does not by itself guarantee calibration.

Related concepts

More concepts starting with D