Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 6Naam in de cursus: Model monitoring

Monitor models in production

A model API can be "up" and still give bad answers. Monitor two layers: the service (latency, errors, cost — like any API) and the model (input drift, prediction drift, quality when the true answers arrive).

  • 4 Lessen
  • 0 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

6.1

Watch the service

Export metrics in Prometheus format and alert like for any API.

metrics.py
from prometheus_client import Counter, Histogram, make_asgi_app
 
PREDICTIONS = Counter("predictions_total", "Predictions served", ["model_version", "result"])
LATENCY = Histogram("prediction_seconds", "Time per prediction")
# in the /predict handler:  with LATENCY.time(): ...   PREDICTIONS.labels("v3", "ok").inc()
metrics_app = make_asgi_app()
MetricAlert when
Error rateAbove 1 % for 5 minutes
p95 latencyAbove the agreed limit
Requests per secondSudden drop (clients broken) or spike (abuse)
GPU / CPU use, costOver budget

6.2

Detect data drift

Drift = the live inputs (or outputs) no longer look like the training data. The model may still answer, but worse.

DriftExample
Data driftAverage order value doubled after a price change
Concept driftFraud patterns changed; old rules learned by the model no longer hold
Prediction driftThe model suddenly says "fraud" twice as often
drift_report.py
import pandas as pd
from evidently import Report
from evidently.presets import DataDriftPreset
 
reference = pd.read_parquet("training_sample.parquet")
current = pd.read_parquet("last_24h_inputs.parquet")
report = Report([DataDriftPreset()])
result = report.run(current_data=current, reference_data=reference)
result.save_html("drift.html")

6.3

Measure real quality

When the true answers arrive later (was it really fraud?), join them with the logged predictions and compute the real metrics.

  • Log every prediction with an ID, the model version and the inputs (without sensitive data where possible).
  • Store the true labels when they come in.
  • A daily job computes precision/recall per model version and alerts on a drop.

6.4

Close the loop

Monitoring triggers action.

SignalAction
Drift above the limitStart the training pipeline with fresh data
Quality dropRoll back to the previous champion
Latency / cost problemScale, use a smaller model, batch requests

Onthoud

Monitoring without an owner and an action is just a dashboard. Decide who reacts to every alert.