AI visualization of metrics
1) What is AI imaging
AI visualization of metrics is a contour where models (ML/LLM) automatically:1. selecting an appropriate graph type and axis
2. highlight patterns/anomalies/trend fractures,
3. formulate explanatory text (insight/narrative),
4. suggest actions (Next Best Action),
5. adapting the view to the context of the user and the device.
The goal is to shorten the path from question to answer: less manual chart selection, more verifiable meanings.
2) Architecture in the palm of your hand
1. Semantic Layer: uniform definitions of metrics/dimensions (glossary, formulas, aggregations, accesses).
2. NL→Query-Converts a natural language query to SQL/SPARQL/DSL.
3. Query→Viz: auto-selection of graphics grammar and parameters (axes, log scales, color/shape/size).
4. Insight Engine: anomaly detection, breakpoints, seasonality, causal hints; signal priorities.
5. Narrative: generation of actual text with reference to values and confidence intervals.
6. RAG: Context blending from the data/configuration catalog (metadata, business rules).
7. Policy Guardrails: privacy/access/masking, verification of numbers and references.
8. Delivery: web widgets, mobile cards, PDF/snapshots, webhooks in CRM/Slack.
3) Grammar of graphs and auto-selection
Principles:- Time → line/area; categories (≤8) → columns/tiles; ranking → bar/leadboard; distribution → histogram/violin/box; scatter/heatmap → correlations.
- Log-axis at exponential growth; normalization (%) at fractions; small multiples - when there are many episodes.
- Color selection: semantic palettes for statuses; color ≠ both order and category channel.
- Signatures only carry meaning: we minimize "ink."
yaml chart:
mark: line encoding:
x: {field: dt, type: temporal, timeUnit: day}
y: {field: ggr, type: quantitative, aggregate: sum}
color: {field: region, type: nominal, legend: top, limit: 6}
transforms:
- filter: "dt >= now()-90d"
- calculate: {expr: "rolling_mean(ggr,7)", as: "ggr_7d"}
annotations:
- rule: {type: "changepoint", method: "cusum"}
- band: {type: "confidence", metric: "ggr", level: 0.9}
interactions: {tooltip: true, zoom: "x", brush: "x"}
4) NL→Viz: from question to schedule
Intention parsing: metric, sections, period, filters, aggregates.
Validation on semantic layer: only allowed fields/formulas.
Post-processing: chart selection by field type and cardinality, auto-threshold binning/sampling.
Feedback: Show SQL/DSL and data download (masked) to build trust.
yaml ask: "Покажи GGR по странам за 90 дней, выдели резкие изменения"
metric: ggr dims: [country, dt]
filters: {dt: "last_90d"}
viz_hint: "line + changepoints"
5) Insight Engine: How to generate "meanings"
Signals:- Anomalies: STL decomposition, ESD/Prophet, BOCPD; label direction/magnitude/trust.
- Trend fractures: CUSUM/Chow test; local regressions.
- Seasonality/campaigns: comparison "holiday vs regular day," uplift to baseline.
- Driver segment: Shapley/feature importance over tabular regression or gradient boosting.
- Causal cues: indication of concomitant changes (within observation) + reminder "this is a correlation."
1. impact on business metric, 2) effect strength, 3) novelty, 4) confidence.
6) Narrative (text) generation
Requirements: facts with numbers and dates, indication of comparison basis, accuracy of terms.
Template:7) Context adaptation (personalization)
Roles: C-level - KPI cards and narratives; managers - cuts and alerts; analytics - SQL/DSL and model parameters.
Device: compact sparklines on mobile, full viz on desktop.
Geo/language/currency/time zone - automatic.
8) Explainability and trust
Each signature on the graph is clickable → reveals the calculation (formula, aggregations, filters).
We indicate statistical uncertainty (confidence bars, error bars).
For LLM descriptions: RAG by metadata, reconciliation of numbers by source (checking amounts/ranges).
Change log: version of formulas, datasets, chart.
9) Visualization quality and SLO
Latency p95 rendering, time-to-first-insight, share of successful NL requests.
Explainability score (presence of numbers/links/CI in the narrative).
Accuracy NL→SQL (ex. exact-match on reference queries).
Accessibility: contrast, alt-text, keyboard, color blindness mode.
10) Availability (A11y) and UX patterns
Color palettes that do not depend on color perception; duplication color-form/pattern.
Text alternatives and data-table view next to the graph.
Focus traps, reasonable tab order; scaling without breaking axes.
11) Security and privacy
RLS/CLS at the request and data level of tooltips.
Masking/bining for rare categories to avoid re-identification.
NL Question Logs - PD Safe: Tokenization/Revision of Potential PIIs.
Export screenshots/CSV - with a watermark and version metadata.
12) Economics and cost
Cost-aware: caching tiles/results, materializing "hot" storefronts, sampling for previews.
Restriction of "heavy" NL requests (scan caps), delayed rendering for large series.
Cheap models for basic detection + heavy offline ratings at night.
13) Antipatterns
"Auto Chart is always right." Validation of types/cardinalities/metric logic is needed.
Too much ink. Complex 3D/dual-axis without the need for → distortion.
No uncertainty. The lyrics sound "categorical" but misleading.
NL→SQL without semantic layer. Fragility and aggregation errors.
Magical insights without reference to numbers. Distrust and abandonment of the instrument.
14) Implementation Roadmap
1. Foundation: semantic layer, glossary of metrics, accesses (RLS/CLS), test sets of NL→SQL.
2. MVP NL→Viz: top 10 questions, grammar auto-chart, type/cardinality validation.
3. Insight Engine: anomalies/breakpoints, priorities, basic narratives with CI.
4. RAG & Trust: connect metadata/formulas, evidence log in UI.
5. A11y and mobile: adaptive cards, alt-texts, contrast/keyboard.
6. FinOps: caches/materializations, scan limits, load profiles.
7. Scale: personalization by role, scenario NLG templates, CRM integrations/alerts.
15) Pre-release checklist
- Metrics and dimensions are described in the semantic layer; SELECT is not allowed.
- Auto chart selection is validated by type/cardinality/rules.
- Narratives contain numbers, comparison, basis, and confidence range.
- Error-bars (where applicable) are included.
- NL→SQL/DSL passes benchmarks; view SQL for the user.
- RLS/CLS and masking work in tooltips/exports.
- A11y: contrast, alt texts, tab navigation, color blindness mode.
- Cache/materializations/scan limits configured; SLO/cost panels collected.
- Formula/chart version logs; button "complain about insight."
16) Mini templates
16. 1 Auto-fit schedule policy
yaml auto_chart_policy:
time_series: ["line","area"]
categories_max: 8 distribution: ["histogram","boxplot"]
correlation: ["scatter","heatmap"]
choose_log_scale_if: growth_rate>0.15/week small_multiples_if: series_count>6
16. 2 Insight Card
yaml insight:
id: "ggr_tr_spike_2025_10_12"
metric: ggr segment: {country: "TR", device: "Android"}
change: {type: "wow", delta_pct: 12.4, ci95: [9.8,14.7]}
drivers: ["Sports +18%", "Slots +7%"]
confidence: 0.86 actions: ["увеличить лимит кампании TR Android на 10%"]
disclaimer: "наблюдение, не доказанная причинность"
16. 3 Example of NL→SQL in UI (backlit)
sql
-- Вопрос: "Как менялся ARPPU по устройствам за 30 дней?"
select dt::date as dt, device_os, avg(revenue_per_payer) as arppu from mart_daily_player where dt >= current_date - interval '30 day'
group by 1,2 order by 1,2;
16. 4 Test kit for NL→Viz
yaml tests:
- ask: "Покажи распределение депозитов за неделю"
expect:
chart: "histogram"
binning: true field: "deposit_amount"
17) The bottom line
AI visualization of metrics is not "clever pictures", and through process: semantic layer → NL→Query → Query→Viz → Insight Engine → explainable narratives → actions and control of trust. With the right guardrails (privacy, number checking, uncertainty, A11y, FinOps), it turns reporting into operational solutions, speeds up analysis and raises the culture of working with data throughout the organization.