Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Machine Learning Professional

Model quality over time and custom metrics

Databricks Machine Learning Professional · Lesson 20 of 22 · 2:22:38

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.

In this lesson

Prepare for the Databricks Certified Machine Learning Professional exam. In this lesson: querying model quality over time from the profile metrics table, aggregate and drift custom metrics, slices, and granularities. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

A stable average

Pebblecove's cancellation model has an inference profile, and its overall quality looks stable, week after week. Yet hosts in the mountain region see a different picture: cancellations the model missed, again and again. This lesson covers tracking model quality over time with an inference table, adding custom metrics, and reading metrics by slice and by granularity.

Quality over time

To track quality, the inference table must hold both the prediction and the label. Labels often arrive later, like a cancellation known only at the date of the stay, so a scheduled job joins them to the logged requests on a request id, and fills the label column. With a label column and a prediction column, the profile metrics table adds quality metrics for each window: accuracy, precision, recall, F1, and the area under the ROC curve for a classifier, and errors like the root mean squared error for a regression. Query these rows in window order, for the whole table and for each model id, to see the trend over time, and compare it with the quality measured at deployment. A falling trend over several windows, rather than a single bad window, is the signal to investigate, or to retrain.

Custom metrics

When the built in metrics miss a business measure, add a custom metric, defined as a SQL expression in a Jinja template. An aggregate metric reads the columns of the table, like a weighted error, where a missed cancellation in high season costs twice as much, and it lands in the profile metrics table. A derived metric is computed from aggregate metrics already calculated, like the square root of an average, without reading the table again. A drift metric compares an aggregate or derived metric between two windows, or with the baseline, and it lands in the drift metrics table. Prefer derived and drift metrics where possible, since only aggregate metrics scan the primary table.

Slices

Every metric is computed for the whole table, and for each slice of the slicing expressions. A column, like country, gives one slice per value, while a condition, like stays longer than seven nights, gives two slices, true and false. In the metric tables, the slice key and slice value columns identify each slice, and both are null for the whole table. And an inference profile also computes every metric for each model id, so two versions can be compared on the same windows.

Granularities

Granularities set the length of the windows, and a profile can have several at once. A window of one day reacts quickly, but it is noisy on small slices, while a window of one week or one month is steadier, and slower to react. Metrics are computed for every combination of window, slice, and model id, so the dashboard and the queries can filter on each of them. For Pebblecove, a weekly query on the F1 score per region shows the mountain region falling, while the whole table stays stable. Large slices dominate the average, so check the important slices, and not only the whole table.

Recap

Let's recap. Quality over time needs the prediction and the label in the inference table, with late labels joined by a job. The profile metrics table then holds quality metrics per window, per slice, and per model id. Custom metrics come in three types: aggregate, derived, and drift. Slicing expressions give one slice per value, or true and false for a condition, and null slice columns mean the whole table. And granularities trade reaction speed against noise, so check important slices, not only the average.

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.

  1. The inference profile of the cancellation model shows drift metrics, but no accuracy at all. What is most likely missing?

    • A baseline table
    • A slicing expression
    • A shorter granularity
    • The label column, filled with joined labels
    Show the answer

    The label column, filled with joined labels

    Quality metrics need both a prediction column and a label column, so the labels must be joined to the table. “A baseline table” only adds baseline drift. “A slicing expression” would add subsets, not quality. And “A shorter granularity” would change the length of the windows, not the metrics.

  2. The team needs the ratio of two aggregate metrics already computed, without scanning the table again. Which type of custom metric fits?

    • Aggregate
    • Drift
    • Derived
    • A new slicing expression
    Show the answer

    Derived

    A derived metric is computed from aggregate metrics already calculated, without reading the table. “Aggregate” would scan the primary table again. “Drift” would compare a metric between two windows, or with the baseline. And “A new slicing expression” would create subsets, not a new metric.

  3. A slice of a few hundred bookings a day shows its accuracy jumping up and down from one day to the next. What helps?

    • A coarser granularity, like one week
    • Removing the slicing expression
    • A drift metric on the whole table
    • A snapshot profile instead
    Show the answer

    A coarser granularity, like one week

    A longer window gathers more rows per slice, so the metric becomes steadier. “Removing the slicing expression” would hide the slice that the team wants to watch. “A drift metric on the whole table” would look at the whole table, not the slice. And “A snapshot profile instead” would drop the time windows altogether.