Module 4 · step 3 of 5 · Training and comparing runs
Metrics that matter
Choose the metric that matches the cost of a wrong prediction, not the one that looks best.
Concept7 min
In this step you will learn which metric answers which question and where mlflow shows each one: the leaderboard columns, the ranking caption and the Plots tab. It matters because the model that wins one metric can lose another, and picking the metric after the fact is the easiest way to fool yourself.
The idea
A metric is a question you ask a model, and the right question comes from the cost of being wrong. In churn prediction only a minority of customers leave, so a model that predicts "stays" for everyone is right most of the time and useless. The main classification metrics:
- Accuracy: what fraction of all predictions were right? It misleads when one class is rare.
- Recall: of the customers who really left, how many did we catch? Choose it when missing a churner is expensive.
- Precision (shown as Prec.): of the customers we flagged, how many really leave? Choose it when each retention offer costs money.
- F1: the harmonic mean of precision and recall, one number when both matter.
- AUC: how well the model ranks leavers above stayers, whatever threshold you pick.
- MCC and Kappa: balanced scores that stay honest with imbalanced classes.
For regression, MAE is the average miss in the target's own units, RMSE punishes big misses harder and R2 is the share of variance explained. Error metrics are better when lower, the others when higher. A score is also an average over cross-validation folds, so small gaps are noise, and it only means something next to the Baseline: 90% accuracy is not impressive when always guessing the majority class scores close to that.
Step by step
- Open a finished run and go to the Leaderboard tab. In All models, find one column per metric and the caption that states the ranking metric, for example
ranked by Accuracy. - When no metric was chosen, mlflow ranks classification runs by Accuracy, regression runs by R2 and time series by MASE. Click any heading to re-sort; mlflow knows the direction of each metric.
- Read the Baseline row as the score to beat.
- Select View details on a candidate. On its Overview tab the primary metric is marked and says whether lower or higher is better.
- Open the Plots tab. Under Diagnostics and Curves, read the Confusion matrix, ROC curve, Precision-Recall and Threshold sweep: they show what a single number hides.
- If missing a positive case is costly, set Optimize metric to Recall when you tune a model, which you do in the step after the leaderboard.
Common mistakes
- Trusting accuracy on imbalanced data. Read the Confusion matrix to see the classes behind it.
- Choosing a metric after seeing which one flatters your favourite model. Decide before you train.
- Reading a tiny difference as a win. The Compare tab marks such gaps as tie.
- Ignoring Training time and Model size when two candidates score alike.
- Confusing a ranking metric (AUC) with a decision threshold. Threshold sweep is where you see what a cut-off does.
As a data scientist
Write down the metric and the cost of each kind of error before the first run, and report the metric next to the baseline, never alone. When you share a result from mlflow, keep the ranking caption in view: someone who reads "best model" without "ranked by" cannot judge it.
To go deeper, read Classification metrics, Precision-recall curves and ROC and AUC.