How MPM worksΒΆ
This page explains what MPM stores, how it turns that into charts, and the concepts the rest of the MPM guides assume. It does not require any knowledge of SQL or of the underlying database.
What MPM is forΒΆ
A model in production makes predictions, and two things can go wrong without announcing themselves:
- The world changes. The applicants arriving today do not look like the ones the model was trained on. The model still returns confident answers; they are just increasingly wrong.
- The model gets worse at its job. It was 92% accurate at launch and it is 71% accurate now, and nobody notices until someone runs a report.
MPM notices both. It stores every prediction your model makes, and lets you chart it, alert on it, and investigate it over time.
What MPM storesΒΆ
Each time your model makes a prediction, your application sends MPM an event with three kinds of content:
| Kind | Meaning | Example |
|---|---|---|
| Input features | What the model was shown | amount = 240.50, country = "UK" |
| Predictions | What the model said | score = 0.87, class = "fraud" |
| Labels (ground truth) | What actually turned out to be true | response = 1 |
The third is special: it usually arrives later. You learn whether a transaction was really fraudulent days after predicting it, so labels are attached to an existing prediction afterwards, matched by prediction ID. See Ground truth.
Each model's events are stored in their own table, with a prefix on each column showing what it is:
__time timestamp feature_amount feature_country prediction_score label_response
βββββββββ ββββββββββ ββββββββββββββ βββββββββββββββ ββββββββββββββββ ββββββββββββββ
08-01 09h 175β¦000 240.50 UK 0.87 1
08-01 10h 175β¦600 18.00 IE 0.02 0
08-01 11h 175β¦200 990.00 UK 0.94 (not yet)
Those prefixes are how MPM knows what each column is, and which charts it can appear in:
| Prefix | Meaning |
|---|---|
feature_ | An input to the model |
prediction_ | An output of the model |
label_ | Ground truth |
You use the full column name, prefix included, whenever you refer to a column β for example in a custom metric formula.
Two kinds of questionΒΆ
MPM answers two quite different questions, through different machinery.
"What is this number, over time?"ΒΆ
You write a formula and MPM charts it per hour or per day:
SELECT ACCURACY("label_response", "prediction_class") FROM MODEL
This is a custom metric, written in a small SQL-like language. MODEL is a keyword standing in for your model's table β you never name the table. See Custom metrics.
"Has the shape of this data changed?"ΒΆ
Drift asks something subtler: not "what is the average?" but "is this column's whole distribution different from what it used to be?"
Picture last month's transaction amounts and this month's as two histograms. Drift is a single number summarising how different those two pictures are:
Reference (training, or the previous period) Current period
βββ
ββ
ββ βββ
ββ
ββ
ββββββββββββββββββββββ ββββββββββββββββββββββ
^ centred low ^ shifted right
drift score: 0.34 β "quite different"
You do not write a formula for drift. You choose a column and an algorithm. See Drift.
For a model that outputs a probability rather than a class, how well that probability ranks the outcome is a separate question β see Classification performance.
How a custom metric becomes a chartΒΆ
you type a formula
β
βΌ
the editor checks it as you type β errors are underlined immediately
β
βΌ
saved (the formula text is stored, not a query)
β
βΌ
translated into a database query β time buckets, filters and names added
β
βΌ
the database runs it
β
βΌ
results become one line per metric per filter
β
βΌ
chart
Two steps are worth understanding, because they explain most of MPM's behaviour.
Everything is grouped into time buckets. A custom metric is always "this value, per hour" or "per day". You never write the grouping; MPM adds it. This is why a metric formula has to reduce to a single number β that number is what gets plotted for each bucket.
Filters become extra columns, not extra queries. The filters you set on a dashboard (its predicates) are applied to each metric separately, so one metric with three filters produces three lines on the chart from a single query.
Metrics that look backwardsΒΆ
Some questions cannot be answered one bucket at a time:
- "How many predictions in total so far this month?" β a running total.
- "What is the 7-day rolling average volume?" β a sliding window.
Both need values from other buckets. MPM supports these through window functions:
SELECT SUM("feature_amount") OVER (ORDER BY timeBucket) FROM MODEL
buckets: Aug 1 Aug 2 Aug 3 Aug 4 Aug 5
daily: 10 20 30 40 50
running: 10 30 60 100 150 β the running total
Because a running total has to be built from the per-bucket values, only measures whose parts add up to the whole can carry a window β sums, counts, minimums and maximums. A running total of per-bucket averages is not an average of anything, so averages and rates are not accepted. See Window functions.
AlertingΒΆ
Anything you can chart, you can monitor. A monitor watches a metric and fires when it crosses a threshold you set, using a comparison you choose β greater than, less than, or either of those with equality. Drift is monitored the same way as any other metric, with the threshold set per alert.
Putting it togetherΒΆ
your application
β prediction made ground truth arrives later
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β event storage: feature_* prediction_* label_* β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β custom metrics β drift
β (a formula you wrote) β (a column + algorithm you picked)
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β charts and alerts β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
GlossaryΒΆ
| Term | Meaning |
|---|---|
| Event | One prediction and everything known about it |
| Ground truth / label | What actually happened, usually learned later |
| Feature | An input to the model |
| Time bucket | The hour or day a metric is grouped into |
| Predicate | A dashboard filter, producing its own line on a chart |
| Custom metric | A formula you write, charted over time |
| Drift | A single number for how much a column's distribution changed |
| Window function | A calculation over other buckets, such as a running total |
Where to nextΒΆ
| Page | What it covers |
|---|---|
| Custom metrics | Writing formulas, the full function reference |
| Window functions | Running totals and rolling windows |
| Drift | The four drift algorithms and how to choose between them |
| Ground truth | Late labels, and monitoring the target column |
| Classification performance | ROC AUC, KS, Gini and the gains table |