Concepts / Choosing Evaluation Metrics for Multiclass and Regression Tasks

Choosing Evaluation Metrics for Multiclass and Regression Tasks

Under this belief, the evaluation score is the target, and the job of machine learning is to push that number as high as possible.

  • Programming

The Model That Scored 99 Percent

When a learner first trains a classifier, the natural habit is to look at one number, usually accuracy, and pick the model with the highest value. That habit feels rigorous, and in many small exercises it works. This lesson examines the belief behind that habit: that the metric you compute during development is the goal itself. That belief is usually wrong, and seeing why is the first step toward choosing a metric well.

What do you think happens?

Suppose a dataset has 1000 images, and only 10 of them are the positive class the application is looking for. A model predicts negative for every single image and never predicts positive. What is its accuracy?

  • About 1 percent

  • 50 percent

  • 99 percent

  • 100 percent

Reveal answer
Answer:

99 percent, computed as $\frac{990}{1000} = 0.99$

The model is correct on all 990 negative images, so accuracy is 99 percent. Yet it finds none of the 10 positive cases. A high score here hides a model that fails at the very thing the application exists to do.

Tracing the 1000 Predictions

Worked example

Following each prediction of the always-negative model

A dataset holds 1000 images, 10 positives and 990 negatives. A model predicts negative for all of them. Trace where each prediction lands and compute accuracy.

  1. 1
    Split the dataset by true class

    There are 10 positive images, the class we are looking for, and 990 negative images.

  2. 2
    Check the negatives

    The model predicts negative for all 990 negatives, so all 990 of those predictions are correct.

  3. 3
    Check the positives

    The model predicts negative for all 10 positives. None of them are found, so all 10 are missed.

  4. 4
    Compute accuracy

    Accuracy is the number of correct predictions divided by the total, which is $\frac{990}{1000} = 0.99$.

Result

Accuracy is 99 percent, yet the model misses every positive case. The single accuracy number averages together a perfect result on the common class and a complete failure on the rare class.

Positive images10 in totalNegative images990 in totalFound by model0Correctly rejected990Missed by model10
Which predictions does the 99 percent accuracy count as successes, and which positive cases does it quietly fail on?

Prediction Scores Versus Business Metrics

The misconception behind the accuracy habit is this: if model A has a higher evaluation score than model B, then model A is the better choice for the application. Under this belief, the evaluation score is the target, and the job of machine learning is to push that number as high as possible. The correction is that people are interested not just in making accurate predictions, but in using those predictions as part of a larger decision-making process. The prediction is an input to a decision, and the decision is what has consequences in the world.

Before picking a machine learning metric, think about the high-level goal of the application. This goal is called the business metric. Examples include avoiding traffic accidents, decreasing the number of hospital admissions, getting more users for a website, and having users spend more money in a shop. Each is stated in the language of the organization or the people the system serves, not in the language of a model. A prediction score, by contrast, is a number computed from the model's outputs on a test set. The business metric is what you want to improve; the prediction score is a measurement you can compute during development.

Business Impact of Choosing an Algorithm

The consequences of choosing a particular algorithm for a machine learning application are called the business impact. The distinction matters. The business metric is what you want to improve. The business impact is what actually happens to that goal when you deploy one algorithm instead of another. Assessing the business impact of a particular model might require putting it into a real-life system, which is often difficult to do.

Business impact can also be more than a single number. Consider a model whose consequence is that you gain 10 percent more customers, but each customer spends 15 percent less. The evaluation should still capture the expected business impact of choosing one model over another, which means combining these effects rather than looking at either one alone.

Worked example

Combining two opposing effects

Model B brings 10 percent more customers than model A, but each customer spends 15 percent less. What is the net change in total spending?

  1. 1
    Write the customer factor

    Ten percent more customers multiplies the customer count by 1.10.

  2. 2
    Write the spending factor

    Fifteen percent less spending per customer multiplies spending by 0.85.

  3. 3
    Multiply the factors

    The total spending factor is $1.10 \times 0.85 = 0.935$.

  4. 4
    Interpret the result

    Total spending is about 6.5 percent lower, even though the customer count went up.

Result

A metric that looks only at customer count would prefer model B. The combined business impact shows that model B reduces total spending, so the decision depends on the full consequence.

When a Surrogate Stands In

Why not simply measure business impact directly? In early development, and when tuning parameters, it is often infeasible to put models into production just for testing, because the business or personal risks can be high. Consider evaluating the pedestrian avoidance of a self-driving car by letting it drive around before verifying it. If the model is bad, pedestrians are the ones who suffer.

The remedy is a surrogate evaluation procedure: an evaluation metric that is easier to compute than the business metric. For the pedestrian case, one surrogate is to test whether the model can classify images of pedestrians versus non-pedestrians, and then measure accuracy on that test. The surrogate is a stand-in that lets you learn something before the expensive or dangerous real-world test.

A surrogate is only a surrogate, so it pays off to find the metric closest to the original business goal that is still feasible to evaluate. That closest metric should be used whenever possible for model evaluation and selection. A surrogate that is easy to compute but far from the goal can lead you to choose the wrong model with great confidence.

Business metrichigh-level goal, such asfewer accidentsSurrogate metriceasier to compute stand-inModel predictionscorefor example, accuracy on atest setBusiness impactconsequences of the chosenalgorithmapproximated bycomputed aschosen model leads tomoves
The business metric is approximated by a surrogate, the surrogate is computed as a prediction score, and the chosen model's real consequences flow back to the business goal.

Why Accuracy Misleads on Binary Tasks

Binary classification is arguably the most common and conceptually simple application of machine learning in practice, yet even this task has caveats. For binary classification we speak of a positive class and a negative class, where the positive class is the one we are looking for. Measuring accuracy can be misleading, and the choice of metric should reflect the positive class and the real goal rather than a single score.

  • Common mistake

    Treating the highest accuracy as the best model

    What it looks like

    A model that always predicts negative on the 1000-image dataset scores 99 percent accuracy.

    Why it fails

    Accuracy counts every correct prediction equally, so a large majority class can dominate the score even when the rare positive class is never found.

    Do this instead

    Ask what the positive class means for the application and whether the metric reflects that goal.

  • Common mistake

    Assuming the development score is the goal

    What it looks like

    Choosing model A because its test score is higher, without asking what happens after deployment.

    Why it fails

    The prediction score is an input to a decision. The real target is the business metric, and the business impact of the chosen model may differ from the score.

    Do this instead

    Connect the score back to the business metric and, where possible, to the business impact.

  • Common mistake

    Choosing an easy surrogate that is far from the goal

    What it looks like

    Measuring image classification accuracy when the real goal is avoiding harm on the road.

    Why it fails

    A surrogate that is easy to compute but distant from the goal can make a wrong model look correct with great confidence.

    Do this instead

    Pick the closest metric to the business goal that is still feasible to evaluate.

Scope of This Lesson

Practice Choosing a Surrogate

MEDIUM

A team wants a model that reduces hospital admissions. Before picking a metric, name the business metric. Then propose one surrogate evaluation procedure that is easier to compute than measuring admissions directly, and explain one way it could still mislead the team.

Hints
  • The business metric is the high-level goal stated in the language of the people the system serves.
  • A surrogate should be as close to the business goal as is still feasible to evaluate.
  • Think about whether a high score on your surrogate would guarantee fewer admissions.

Key Takeaways

  • A business metric is the high-level goal of an application, such as fewer accidents or more purchases, and it is different from a model's prediction score.
  • Business impact is the set of consequences of choosing one algorithm, and it may only be fully assessed by putting a model into production.
  • When production testing is too risky or infeasible, a surrogate evaluation procedure uses an easier-to-compute metric, and the closest feasible metric to the goal should be preferred.
  • In binary classification, accuracy can mislead: a model that always predicts the majority class can score 99 percent while missing every positive case.

Related concepts

More concepts starting with C