Evaluation metrics
Databricks Machine Learning Associate · Lesson 15 of 19 · 1:56:22
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Databricks Certified Machine Learning Associate exam. In this lesson: classification metrics (accuracy, precision, recall, F1, and the area under the ROC curve), regression metrics (RMSE, MAE, and R squared), choosing a metric by the cost of errors, and metrics on a log scale. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Two numbers
The damage classifier and the repair cost model of Juniper Rides each report one number: ninety eight percent accuracy, and an RMSE of 0.4. The first number hides a useless model, and the second is on a log scale, so nobody knows what it means in dollars. This lesson covers classification metrics, regression metrics, how the cost of errors picks the metric, and how to read metrics on a log scale.
Classification metrics
Classification metrics start from four counts: true positives, false positives, true negatives, and false negatives. Accuracy is the share of correct predictions, which misleads with imbalanced classes. Precision is the share of predicted positives that are real, and recall is the share of real positives that the model finds. F1 is the harmonic mean of precision and recall, high only when both are high. The area under the ROC curve measures how well the model ranks positives above negatives, across all thresholds, while the area under the precision recall curve focuses on a rare positive class. And log loss scores the predicted probabilities, and heavily penalizes a confident wrong prediction.
Regression metrics
RMSE, the root mean squared error, squares the errors before averaging them, so it penalizes large errors heavily, and it is in the unit of the target. MAE, the mean absolute error, averages the absolute errors, so it is easier to read, and more robust to outliers. R squared is the share of the variance of the target that the model explains, one being perfect, and it can even be negative, when a model does worse than predicting the mean. In Spark ML, the RegressionEvaluator computes RMSE by default, and also MAE and R squared, while the MulticlassClassificationEvaluator computes F1 by default, and also accuracy and log loss. And the BinaryClassificationEvaluator computes the area under the ROC curve by default, or under the precision recall curve.
The cost of errors
The right metric follows from what each error costs the business. When false negatives are costly, like a damaged scooter left in service, favor recall, so that few real cases slip through. When false positives are costly, like a technician sent to a scooter that is fine, favor precision, so that alerts stay reliable. When both matter, F1 balances them, and the decision threshold can then move toward the costlier error. For regression, choose RMSE when large errors are especially costly, and MAE when every unit of error costs the same.
Metrics on a log scale
When a model predicts the log of a skewed target, like the log of a repair cost, its predictions are on the log scale. An RMSE computed on those values is in log units, so it does not say how many dollars the model misses by. To report errors in real units, take the exponent of the predictions first, with exp, or expm1 if the target used log1p, and then compute RMSE or MAE against the real costs. Taking the exponent of an RMSE in log units does not give the RMSE in real units, since the transformation is not linear. And on the log scale, an error stands for a ratio, not a difference, so the same log error means bigger misses on expensive repairs.
Recap
Let's recap. Precision is the share of predicted positives that are real, recall is the share of real positives found, and F1 balances them. The area under the ROC curve measures ranking across thresholds, and log loss scores probabilities. RMSE penalizes large errors, MAE is robust and easy to read, and R squared is the share of variance explained. Favor recall when false negatives cost more, and precision when false positives do. And with a log target, take the exponent of the predictions before computing errors in real units.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
The damage classifier flags 100 trips, and 80 of them really end with damage. The data holds 200 damaged trips in all. What are its precision and its recall?
- Precision 0.8, recall 0.4
- Precision 0.4, recall 0.8
- Precision 0.8, recall 0.8
- Precision 0.5, recall 0.4
Show the answer
Precision 0.8, recall 0.4
Precision is eighty correct out of 100 flagged, so zero point eight, and recall is eighty found out of two hundred real cases, so zero point four. “Precision 0.4, recall 0.8” swaps the two. “Precision 0.8, recall 0.8” uses the flagged trips for both. And “Precision 0.5, recall 0.4” divides the flagged trips by the real cases, which is neither metric.
The demand model misses by a few rides on most days, but by hundreds of rides on event days, and those big misses are what costs money. Which metric should the team track?
- MAE, the average absolute error
- R squared, the variance explained
- Accuracy of rounded predictions
- RMSE, which squares the errors
Show the answer
RMSE, which squares the errors
Squaring the errors makes the big misses weigh much more, which matches their cost. “MAE, the average absolute error” weighs every ride of error the same, so the big misses count less than in RMSE. “R squared, the variance explained” measures the share of variance explained, not the size of the costly errors. And “Accuracy of rounded predictions” is a classification metric, which does not fit a count of rides.
A model predicts log1p of the repair cost, and the team wants its MAE in dollars. What must it do?
- Compute MAE on log values, then expm1 it
- Apply expm1 to predictions, then compute MAE
- Compute MAE on the log values as they are
- Apply log1p to the predictions again
Show the answer
Apply expm1 to predictions, then compute MAE
Expm1 undoes log1p, so the predictions are back in dollars before the MAE is computed against the real costs. “Compute MAE on log values, then expm1 it” transforms the metric instead of the predictions, which gives a wrong value, since the transformation is not linear. “Compute MAE on the log values as they are” reports an error in log units, not in dollars. And “Apply log1p to the predictions again” moves the predictions even further from the real scale.