Before the questions, make sure you can: read and compute a confusion matrix, precision, recall and accuracy, overall and per group; explain ROC and precision–recall curves and choose a threshold for a target; explain what calibration, feature importance and partial-dependence plots show and their limits; detect data drift with a population stability index; design streaming views with windows and percentiles; design alerts with hysteresis that avoid flapping; and connect monitoring dashboards to service-level objectives in edge–cloud systems.
Chapter 12 used AI to make visualizations; this chapter uses visualization to understand AI — and the live systems AI runs in. A model's single "accuracy = 85 %" hides who it fails, at which threshold, and whether the world has changed since it was trained. A service's "average latency = 142 ms" hides the users waiting 371 ms. Visualization is how engineers, managers and regulators see inside these systems, and it is one of the fastest-growing uses of the skills in this course.
Visualization across the ML lifecycle
| Stage | Question | Views |
|---|---|---|
| Data | Is the training data representative and clean? | distributions per feature and group, missing-value maps (Chapters 2, 7) |
| Training | Is the model learning? | loss/metric curves per epoch (train vs. validation) |
| Evaluation | How and for whom does it fail? | confusion matrix, ROC/PR curves, calibration, per-group metrics, error examples |
| Explanation | Why does it predict this? | feature importance, SHAP plots, partial dependence |
| Deployment | Is it still working? | drift monitors, prediction distributions, live performance |
Evaluating a classifier
CityPulse predicts whether a bike station will be empty within an hour (1) or not (0).
Confusion matrix (rows = actual, columns = predicted): TN, FP / FN, TP. From it: accuracy = (TP + TN)/all, precision = TP/(TP + FP) ("when we send a van, how often was it needed?"), recall = TP/(TP + FN) ("of the stations that became empty, how many did we catch?"). In Lab V13.1: accuracy 0.85, precision 0.86, recall 0.75.
Per-group metrics reveal what the overall numbers hide: recall is 1.00 for central stations but 0.50 for peripheral ones — the model misses half of the problems in outer districts, so their residents find empty stations more often. Fairness analysis starts with exactly this view: the same metric, broken down by group, side by side.
Scores and thresholds: most classifiers output a score; a threshold turns it into a decision. Lowering the threshold raises recall and lowers precision.
- ROC curve: true-positive rate vs. false-positive rate over all thresholds; ROC AUC = probability that a random positive gets a higher score than a random negative (0.5 = random, 1 = perfect). In Lab V13.2, AUC = 0.72.
- Precision–recall curve: more informative when positives are rare (imbalanced data), since ROC can look good while precision is poor; summarized by average precision.
- Choosing a threshold is a decision about costs, not a statistical fact: to catch at least 80 % of empty stations, the highest workable threshold is 0.45, at precision 0.67 — one in three van trips is unnecessary. Show the trade-off as a chart, let the operations manager choose.
Calibration (reliability diagram): do predicted probabilities match observed frequencies (of all stations predicted at 70 %, about 70 % should become empty)? Essential when probabilities are shown to users.
Explaining models
- Feature importance — how much a model relies on each feature; permutation importance measures the drop in performance when a feature's values are shuffled.
- SHAP values (Lundberg & Lee, 2017) attribute each prediction to features (a "waterfall" for one prediction; a summary "beeswarm" over many).
- Partial dependence plots show how the prediction changes with one feature, averaged over the others.
Limits: explanations describe the model, not the world (a model may use "station id" as a proxy); correlated features share or steal importance; explanations can be unstable. Present them as diagnostic tools, with care for non-expert audiences.
Monitoring deployed models: drift
The world changes: summer arrives, a new metro line opens, a sensor is replaced. Data drift = the distribution of inputs changes; concept drift = the relation between inputs and outcomes changes. Monitoring compares current data with the training (reference) data:
- Population stability index (PSI) over bins of the reference distribution: PSI = Σ (current% − reference%) · ln(current% / reference%). Common rules of thumb: < 0.1 no significant shift, 0.1–0.25 moderate, > 0.25 significant. In Lab V13.4, temperature shifts massively in summer (PSI 5.85), PM2.5 significantly (0.63), trips moderately (0.13) — retraining or at least investigation is due.
- Views: reference vs. current histograms side by side, PSI per feature over time, prediction distributions, and — when labels arrive later — live precision/recall.
Real-time and streaming visualization
Streams (sensor readings, requests, bike status) are summarized in windows (tumbling: consecutive blocks; sliding: overlapping) with rolling aggregates. For latency and load, percentiles beat means: in Lab V13.3 the overall mean is 142 ms but the 95th percentile is 371 ms — what the slowest 5 % of users experience. Service-level objectives are written on percentiles ("p95 latency < 200 ms").
Alerting turns views into actions:
- Thresholds on meaningful statistics (p95, error rate), not raw single points.
- Persistence: fire only after k consecutive bad windows (avoids alerts on one spike).
- Hysteresis: clear the alert only when the metric falls clearly below a lower threshold (e.g., enter at 200 ms, exit at 150 ms) — otherwise an alert near the threshold flaps on and off.
- Every alert links to a dashboard view of its context (overview + detail, Chapter 8).
Service-level objectives (SLOs) and error budgets (Google SRE practice): if the objective is 99.9 % of requests under 200 ms per month, the "budget" is 0.1 % of requests; dashboards show how much budget remains, which guides whether to ship new features or fix reliability.
Observability stacks: metrics in time-series databases (Prometheus, InfluxDB), logs and traces, dashboards in Grafana (shared time ranges, drill-down from panel to logs), alert managers. Edge–cloud systems — sensors and phones sending data to edge servers that offload heavy work to the cloud — need per-tier views: device health, edge server load and queueing, network latency between tiers, cloud cost; a request's latency is the sum of these, so the dashboard should decompose it.
MLOps platforms (MLflow, Weights & Biases, Evidently, Arize) and cloud model monitors ship standard visualizations: training curves, confusion matrices, drift reports with PSI or KS statistics, and per-segment performance. The design questions of this course — which statistic, which comparison, which audience — decide whether those dashboards prevent incidents or are ignored.
Visual analytics for AI is a major research area at IEEE VIS: tools to inspect model internals, compare models, audit fairness, and monitor deployed systems. In edge–cloud computing, research visualizes task scheduling and offloading decisions (which task ran where, with what latency and energy) to help engineers understand and tune scheduling algorithms — visualization as a debugger for distributed systems.
Key takeaways
- Confusion matrix → accuracy, precision, recall; break metrics down by group to find who the model fails.
- ROC (AUC) and PR curves summarize all thresholds; choosing a threshold is a cost decision — show the trade-off.
- Calibration, permutation importance, SHAP and partial dependence explain models — with limits.
- Monitor drift (PSI: < 0.1 / 0.1–0.25 / > 0.25) and live performance.
- Streams: windows, rolling aggregates, percentiles over means; alerts with persistence and hysteresis; SLOs and error budgets; decompose latency across edge and cloud tiers.
Ready? Close the notes and practise.
30 questions. Predict the output before you check — that is the skill the exam measures.