What you will be able to do
- Turn a business objective into a choice between a decision metric (precision, recall, F1, accuracy) and a probability metric (log loss, ROC AUC)
- Choose recall or precision by comparing the cost of a missed positive with the cost of a false alarm
- Explain why accuracy misleads on a rare positive class, and when F1 is the better single number
- Match RMSE, MAE or pinball loss to the statistic the business wants predicted: the mean, the median or a quantile
- Keep one primary metric for tuning, model selection and production monitoring
Key concept
Objective-derived metric — The evaluation metric comes from what the business needs predicted or decided, not from habit or from whichever model looks best. Once chosen, that one metric drives hyperparameter tuning, model selection and production monitoring.
1.Derive the metric from the scenario objective
A metric defines what "better" means, and every later step works toward it. Hyperparameter search optimizes it, model comparison ranks by it, and monitoring raises alarms on it. So the metric has to come from the scenario's objective before anyone looks at which model scores well on what. The Databricks ML lifecycle puts this question in the first stage, scoping, next to the prediction target and the serving requirements. It asks which metrics define success: accuracy, AUC, precision at K, or a business KPI.
Sometimes the score is already fixed. A contract, a service-level promise or a competition may say exactly how predictions will be judged. In that case, use that score. When you are free to choose, start from what the prediction is for: who reads it and what they do next.
That question has two parts. The first is predicting: which quantity does the model output? A classifier usually returns a probability through predict_proba. A regressor returns a number that is meant to match some property of the target's distribution, such as its mean, median or a quantile. The second is decision making: is the output turned into an action? A typical example is converting a fraud probability into a send-to-review flag at some threshold. Decision metrics are built from the confusion matrix and judge the yes/no outcome. Probability metrics judge the score before any threshold is applied. In most scenario questions, the answer follows once you know whether the business uses the decision or the number.
Checkpoint 1 of 8· Check yourself
A bank's fraud classifier outputs a probability for each transaction. Operations sends a transaction to manual review only when that probability crosses a set threshold, and analysts act only on the resulting review flag. No contract fixes the score. Which kind of metric should judge this model?
The business acts on the thresholded yes/no flag, so the decision is what needs judging, and decision metrics come from the confusion matrix. A probability metric judges the score before the threshold, which is not what the analysts use. Picking the metric because a model happens to score well on it reverses the objective-first order.
“There are many scoring functions which measure different aspects of such a decision, most of them are covered with or derived from the metrics.confusion_matrix.”Source: scikit-learn.org
2.Classification decisions: weigh a miss against a false alarm
Precision is the share of flagged cases that are truly positive. Recall is the share of actual positives that get flagged. F1 combines the two into one number. The formulas are covered in Precision, recall, F1, ROC AUC, log loss. The scenario decides between them by telling you which error is more expensive. Recall penalizes misses (false negatives). Precision penalizes false alarms (false positives).
Databricks frames the same trade-off for retrieval quality. Choose recall when you need all the relevant information: clinical trial matching, for example, cannot miss an eligible patient. Choose precision when you need only the most relevant results: financial deduplication must identify duplicate accounts with high confidence, because a wrong merge does real damage. The setting differs, but the rule carries over to classifiers unchanged.
Take a hospital screening for a rare, life-threatening condition, where a positive flag sends the patient for a follow-up diagnostic test. A missed case can be fatal. A false alarm costs one extra test. That makes recall the primary criterion. Precision would be the wrong choice because it only looks at patients the model flagged and ignores the sick patients it never flagged. Specificity, the true negative rate, is also wrong: it measures how well the model avoids false alarms on healthy patients, which is the error the hospital has said is cheap.
When both errors matter and the business wants one number, use F1. In the fraud case, the business wants to catch fraud (recall) without flooding the review team with false alarms (precision). Accuracy misleads here: on a 0.3% positive class, predicting "legitimate" for everything already scores 99.7%. F1 is built only from precision and recall on the positive class, so that do-nothing model gets an F1 of zero. Regression metrics such as R² or MAE do not fit here at all, because they measure numeric distance and do not judge a class decision.
| Scenario | Costlier error | Primary metric |
|---|---|---|
| Screening for a life-threatening condition before a cheap follow-up test | Missing a true case | Recall |
| Clinical trial matching that cannot miss eligible patients | Missing a true case | Recall |
| Deduplicating financial accounts, where a wrong merge is harmful | Flagging a non-duplicate | Precision |
| Fraud review: catch fraud, but keep the review queue manageable on a 0.3% positive class | Both, so one balanced number is needed | F1 |
Checkpoint 2 of 8· Match them up
Match each metric to the scenario where it should be the primary criterion, based on which error costs more.
Tap a term, then the definition that fits it.
Recall penalizes misses, so it fits when a missed positive is the expensive error. Precision penalizes false alarms, so it fits when acting on a wrong flag does damage. When both errors matter and the business wants one number, F1 combines precision and recall on the positive class.
“If recall matters most (need all relevant information):”Source: docs.databricks.com
Checkpoint 3 of 8· Exam question
A data scientist on Databricks trains a fraud detection classifier where fraudulent transactions make up only 0.3% of the dataset. The business wants a single number that balances catching fraud against not overwhelming the review team with false alarms, and accuracy is known to be misleading on this data. Which metric should the team log with mlflow.log_metric as the primary evaluation score?
Correct answer: A — F1 score, computed with sklearn.metrics.f1_score, since it combines precision and recall into one number that stays informative when the positive class is rare
- A. F1 is the harmonic mean of precision and recall, so it stays low unless both catching fraud and limiting false alarms are handled well, which is exactly the tradeoff the business described. With a 0.3% positive rate this single number remains informative where accuracy would not.
- B. Accuracy is dominated by the 99.7% majority class here, so a model that predicts every transaction as legitimate would still score above 99% while catching zero fraud. That is the exact failure mode the business flagged as misleading.
- C. R-squared measures the proportion of variance explained in a continuous target and is a regression metric, not a classification metric, so it is not defined for a binary fraud label.
- D. Mean absolute error measures the average magnitude of numeric prediction errors and is built for regression targets, not for scoring how well a classifier separates two discrete classes.
Checkpoint 4 of 8· Exam question
A hospital is training a model on Databricks to flag patients who may have a rare but life-threatening condition, feeding a follow-up diagnostic test. Missing a true case is far more costly than sending a healthy patient for an unnecessary follow-up test. Which metric should the team optimize as the primary decision criterion?
Correct answer: A — Recall, computed with sklearn.metrics.recall_score, since it measures the share of true positives the model successfully identifies out of all actual positives
- A. Recall is true positives divided by all actual positives, so it directly measures how many real cases of the condition the model catches. Optimizing recall minimizes missed diagnoses, which matches a scenario where false negatives are the costly error.
- B. Precision measures how trustworthy a positive prediction is, which matters when false positives are expensive, but here an unnecessary follow-up test is described as the cheaper error, so precision is not the priority metric.
- C. Root mean squared error penalizes numeric prediction error and applies to continuous regression targets, not to a binary diagnostic classification decision.
- D. Specificity measures how well the model avoids false alarms on healthy patients, which is the opposite priority from the scenario, where minimizing missed true cases matters far more than minimizing unnecessary follow-ups.
3.When the probabilities matter more than the decision: log loss and ROC AUC
Precision, recall, F1 and accuracy all require a threshold first. Each one scores the yes/no outcome produced after predict_proba is cut at some value. If the business has not chosen that cutoff, or if it uses the probability itself, a threshold-based metric is judging a decision nobody has made. In that case, score the model before the threshold.
Use ROC AUC when the question is how well the model ranks. Suppose a marketing team is comparing lead-scoring classifiers, and sales wants to move the cutoff later depending on how many reps are free. ROC AUC summarizes how well each model ranks positive leads above negative ones across every possible threshold, so whichever cutoff sales picks later, the comparison still holds. F1 or accuracy at the default 0.5 judges one cutoff that nobody has committed to. MAE between lead scores and 0/1 labels treats a class label as a number to approximate, which is a regression measure applied to a ranking problem.
Use log loss when the probability values themselves are consumed, for example when a downstream system multiplies a predicted default probability by an exposure. Log loss is a strictly proper scoring rule for class probabilities: it rewards a model most when it reports honest probabilities, because telling the truth is the optimal strategy in expectation. The Brier score has the same property; it is the squared error between the predicted probabilities and the 0/1 outcomes. These metrics score probabilistic prediction directly, where the model predicts a distribution instead of making a single call. AUC only measures order: two models that rank every case the same way get the same AUC, even if one of them reports probabilities that are all far too high. Log loss would tell those two models apart.
| Metric | Needs a threshold? | What it judges | Pick it when |
|---|---|---|---|
| Precision / recall / F1 | Yes | The yes/no decision | The cutoff is fixed and the error costs are known |
| Accuracy | Yes | Share of correct decisions | Classes are reasonably balanced and both errors cost about the same |
| ROC AUC | No | Ranking of positives above negatives | The cutoff is undecided or will change later |
| Log loss | No | The probability values themselves | Downstream systems use the probability, not just its rank |
Checkpoint 5 of 8· Check yourself
A lender's pricing engine multiplies each loan's predicted default probability by the loan's exposure to set a reserve. Two candidate classifiers rank every loan in exactly the same order, but one reports probabilities that are all far too high. Which metric should decide between them?
The downstream system uses the probability value, so the metric has to judge those values. Log loss scores predict_proba output directly and would penalize the inflated probabilities. ROC AUC only measures order, so the two models would tie. F1 and accuracy judge a thresholded decision that this business never makes.
“mean | log loss | multi-class | predict_proba”Source: scikit-learn.org
Checkpoint 6 of 8· Exam question
A marketing team is evaluating several candidate classifiers trained in a Databricks notebook and has not yet decided on a probability cutoff for ranking leads, since the sales team wants the flexibility to adjust the cutoff later based on capacity. Which metric best compares the classifiers' ability to rank positive cases above negative cases across all possible thresholds?
Correct answer: A — ROC AUC, computed with sklearn.metrics.roc_auc_score, since it summarizes ranking quality across every possible classification threshold in one number
- A. ROC AUC evaluates the true positive rate against the false positive rate across every threshold, so it measures how well a model ranks positives above negatives without committing to a specific cutoff. That matches a scenario where the cutoff is deliberately left open.
- B. F1 at a fixed 0.5 threshold only reflects performance at that one cutoff, so it does not answer how the models compare once the sales team later shifts the cutoff based on capacity.
- C. Accuracy at a single fixed threshold has the same limitation as F1 at that threshold: it reflects one operating point and hides how ranking quality changes as the cutoff moves.
- D. Mean absolute error against binary 0/1 labels is not a standard way to evaluate classifier ranking quality and does not summarize threshold-independent separation between classes the way a ranking metric does.
4.Regression: choose the statistic you want predicted
RMSE, MAE and R² are defined in MSE, RMSE, MAE, R² and variants. For metric choice, what matters is that each loss is minimized by a different summary of the target's distribution. Squared error, which underlies MSE and RMSE, is minimized by the conditional mean. Absolute error (MAE) is minimized by the conditional median. Pinball loss is minimized by a chosen quantile. Here "conditional" means for given input features: the model predicts the mean, median or quantile of the target among cases that share those feature values. So choosing a regression metric is the same as choosing which number you want the model to output.
Pinball loss is the scoring function for a quantile target, and its alpha parameter is the quantile level: alpha 0.99 aims at the 99% quantile, the value the target stays under on 99% of cases.
| Statistic the business wants | Consistent loss / metric | Example objective |
|---|---|---|
| Mean | Squared error (MSE, RMSE; R² ranks the same) | Expected value per prediction, where large errors should weigh heavily |
| Median | Absolute error (MAE) | A typical value that a few extreme cases should not drag around |
| Quantile | Pinball loss | A level that holds on 99% of days |
A quantile objective shows the logic clearly. A network provider promises that on at least 99% of days, no connection drops for longer than one minute. What it needs to predict is the 99% quantile of the longest daily interruption, not the average one, so it uses pinball loss at alpha 0.99. Both RMSE and MAE would train and select a model aimed at the wrong number, however low their scores looked.
Checkpoint 7 of 8· Match them up
Three teams each need a regression model, but each wants a different number predicted. Pair each training and selection metric with the objective it is consistent with.
Tap a term, then the definition that fits it.
Each loss is minimized by a different statistic of the target. Squared error (RMSE) targets the mean and weighs large errors heavily. Absolute error (MAE) targets the median, so a few outliers do not move it much. Pinball loss targets a chosen quantile, here the 95% level.
“median | absolute error | all reals | predict, all reals”Source: scikit-learn.org
5.Use the same metric for tuning, selection and monitoring
Once the objective has given you a metric, use it at every stage. scikit-learn's guidance is to use a strictly consistent scoring function as the training loss and also as the evaluation and model-comparison metric. In the network example, that means quantile loss in HistGradientBoostingRegressor, then mean_pinball_loss with the same alpha in grid search and when comparing against alternative models.
On Databricks, the metric choice has direct effects. AutoML's primary_metric is the metric it uses to evaluate and rank trials, so switching from f1 to roc_auc can change which model is reported as best. The lifecycle guidance says to define evaluation metrics during development from the scoping requirements, log them in MLflow runs so each one stays attached to its model, and reuse them later for production monitoring.
Here is what goes wrong when the stages disagree. A team tunes on accuracy, selects on F1 and monitors AUC. That gives three different definitions of "best", and when the production number drops, nobody can compare it with a development baseline. Secondary metrics are still useful, since no single metric tells the whole story, and Databricks suggests derived metrics such as comparing a base metric across population segments to check fairness. But one metric stays primary, and it is the one the objective pointed to.
Checkpoint 8 of 8· Check yourself
A churn team has agreed that F1 on the churn class is the metric the business objective calls for. One engineer proposes tuning hyperparameters on accuracy, choosing the final model by F1, and tracking ROC AUC in production. What should the team do?
The metric the objective points to should drive training, model comparison and monitoring. Otherwise each stage optimizes a different definition of "best", and a drop in production can't be compared with a development baseline. Secondary metrics are still useful, but they don't replace the primary one. Switching to ROC AUC would drop the metric the objective chose.
“it is best used for both: as loss function for model training and as metric/score in model evaluation and model comparison.”Source: scikit-learn.org
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“What metrics define success: accuracy, AUC, precision at K, or business KPIs?”
↩︎ Derive the metric from the scenario objective“Before building anything, align on what the model needs to do and how you will know it is working.”
↩︎ Derive the metric from the scenario objective“Your base metrics might be common ML metrics like accuracy, AUC, RMSE or domain-specific metrics.”
↩︎ When the probabilities matter more than the decision: log loss and ROC AUC“The metrics you define during development and training can be reused later as metrics for production monitoring.”
↩︎ Use the same metric for tuning, selection and monitoring“During development, define quality evaluation metrics based on the requirements from scoping:”
↩︎ Use the same metric for tuning, selection and monitoring - 2.https://scikit-learn.org/stable/modules/model_evaluation.htmlSecondary source
“if the scoring function is given, e.g. in a kaggle competition or in a business context, use that one.”
↩︎ Derive the metric from the scenario objective“The most common decisions are done on binary classification tasks, where the result of predict_proba is turned into a single outcome”
↩︎ Derive the metric from the scenario objective“which avoids inflated performance estimates on imbalanced datasets”
↩︎ Classification decisions: weigh a miss against a false alarm“One can aim to predict the whole distribution, known as probabilistic prediction”
↩︎ When the probabilities matter more than the decision: log loss and ROC AUC“Note that for regressors, the prediction is done with predict while for classifiers it is usually predict_proba.”
↩︎ When the probabilities matter more than the decision: log loss and ROC AUC“consistent scoring functions act as truth serum”
↩︎ When the probabilities matter more than the decision: log loss and ROC AUC“The Brier score is just a different name for the squared error in case of classification with one-hot encoded targets.”
↩︎ When the probabilities matter more than the decision: log loss and ROC AUC“So the target functional is the 99% quantile.”
↩︎ Regression: choose the statistic you want predicted“From the table above, you choose the pinball loss as scoring function”
↩︎ Regression: choose the statistic you want predicted“the median or a quantile of the response variable”
↩︎ Regression: choose the statistic you want predicted“quantile | pinball loss | all reals | predict, all reals”
↩︎ Regression: choose the statistic you want predicted“it is best used for both: as loss function for model training and as metric/score in model evaluation and model comparison”
↩︎ Use the same metric for tuning, selection and monitoring“If you are free to choose, it starts by considering the ultimate goal and application of the prediction.”
↩︎ Key concept“which avoids inflated performance estimates on imbalanced datasets”
↩︎ Exam trap 1“R² gives the same ranking as squared error.”
↩︎ Exam trap 3“it is best used for both: as loss function for model training and as metric/score in model evaluation and model comparison”
↩︎ Exam trap 4“There are many scoring functions which measure different aspects of such a decision, most of them are covered with or derived from the metrics.confusion_matrix.”
↩︎ Checkpoint“mean | log loss | multi-class | predict_proba”
↩︎ Checkpoint“R² gives the same ranking as squared error.”
↩︎ Prediction“median | absolute error | all reals | predict, all reals”
↩︎ Checkpoint“it is best used for both: as loss function for model training and as metric/score in model evaluation and model comparison.”
↩︎ Checkpoint - 3.
“If recall matters most (need all relevant information):”
↩︎ Classification decisions: weigh a miss against a false alarm“Financial services deduplication: Identifying duplicate transactions or accounts with high confidence.”
↩︎ Classification decisions: weigh a miss against a false alarm“Pharma clinical trial matching: Cannot miss eligible patients or relevant studies.”
↩︎ Exam trap 2 - 4.
“The positive class. This is useful for calculating metrics such as precision and recall.”
↩︎ Classification decisions: weigh a miss against a false alarm“Metric used to evaluate and rank model performance.”
↩︎ Regression: choose the statistic you want predicted“Metric used to evaluate and rank model performance.”
↩︎ Use the same metric for tuning, selection and monitoring - 5.
“No single metric tells the whole story.”
↩︎ Use the same metric for tuning, selection and monitoring