File size: 48,331 Bytes
25af026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jackson Dormer | Forecasting and LLM-agent projects</title>
<meta name="description" content="Results from projects testing when LLM agents add value over strong statistical models: weather forecasting, Premier League and a live sports Instagram account.">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"></script>
<script src="shim.js"></script>
</head>
<body>
<style>

  /* Light business theme: fixed colors (no dark mode), white cards on a light grey canvas, blue accent. */

  html, body { margin: 0; background: #f4f6f9; }

  .pf [hidden] { display: none !important; }

  .pf { max-width: 1180px; margin: 0 auto; --bg: #f4f6f9; --card: #ffffff; --line: #e3e8ef; --head: #f8fafc; --ink: #111827; --text: #374151; --muted: #6b7280;

        --accent: #2563eb; --accent-soft: #eff4ff; --good: #15803d; --good-soft: #ecfdf3; --bad: #b91c1c; --bad-soft: #fef2f2;

        color-scheme: light; background: var(--bg); color: var(--text);

        font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; font-size: 14px;

        display: flex; flex-direction: column; gap: 20px; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }

  .pf p { margin: 0; max-width: 78ch; line-height: 1.55; }

  .pf .eyebrow a { color: inherit; }

  .pf .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }

  .pf h1 { font-size: 24px; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.25; text-wrap: balance; }

  .pf h2 { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.3; text-wrap: balance; }

  .pf h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; }

  .pf .note { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

  .pf .num, .pf table, .pf .figure-value { font-variant-numeric: tabular-nums; }

  .pf b { color: var(--ink); }



  .pf header.intro { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; display: flex; flex-direction: column; gap: 8px;

                     box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }



  .pf nav.tabs { display: flex; gap: 4px; background: #e9edf3; border-radius: 10px; padding: 4px; overflow-x: auto; width: fit-content; max-width: 100%; }

  .pf nav.tabs button { appearance: none; border: 0; background: transparent; border-radius: 7px; padding: 8px 14px; font: inherit; font-size: 13.5px;

                        color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500; }

  .pf nav.tabs button:hover { color: var(--ink); }

  .pf nav.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }

  .pf nav.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }



  .pf section.tab { display: flex; flex-direction: column; gap: 16px; }

  .pf .block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px;

               min-width: 0; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }

  .pf .block.intro { gap: 10px; }



  .pf .figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 6px; }

  .pf .figure { background: var(--head); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }

  .pf .figure + .figure { border-left: 1px solid var(--line); }

  .pf .figure-value { font-size: 24px; font-weight: 600; color: var(--ink); line-height: 1.15; }

  .pf .figure-label { font-size: 12.5px; color: var(--muted); line-height: 1.35; }



  .pf .verdicts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

  .pf .verdict { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

  .pf .verdict .big { font-size: 30px; font-weight: 600; color: var(--ink); line-height: 1; }

  .pf .mark { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;

              background: #f1f5f9; color: var(--muted); }

  .pf .mark.good { background: var(--good-soft); color: var(--good); }

  .pf .mark.bad { background: var(--bad-soft); color: var(--bad); }



  .pf .chart { position: relative; width: 100%; min-height: 240px; }

  .pf .chart svg text { fill: var(--muted); font-size: 12px; font-family: inherit; }

  .pf .chart svg text.ink { fill: var(--ink); }

  .pf .tip { position: absolute; pointer-events: none; background: #ffffff; border: 1px solid var(--line); box-shadow: 0 4px 12px rgba(16, 24, 40, .12);

             border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--ink); white-space: nowrap; z-index: 2; }



  .pf .tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }

  .pf table { border-collapse: collapse; width: 100%; font-size: 13px; }

  .pf th, .pf td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; color: var(--text); }

  .pf thead th { background: var(--head); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

  .pf tbody tr:last-child td { border-bottom: 0; }

  .pf tbody tr:hover td { background: #fafbfd; }

  .pf td.r, .pf th.r { text-align: right; }

  .pf tr.primary td { font-weight: 600; color: var(--ink); background: var(--accent-soft); }

  .pf td.wrap { white-space: normal; min-width: 220px; }



  .pf .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }

  .pf .cols > div { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

  .pf ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; max-width: 78ch; line-height: 1.5; }

  .pf details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 24px; }

  .pf details summary { cursor: pointer; color: var(--ink); font-weight: 600; }

  .pf details dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 13px; }

  .pf details dt { font-weight: 600; color: var(--ink); }

  .pf details dd { margin: 0; color: var(--muted); }

  .pf .legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }

  .pf .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }

  .pf .legend .k-reel::before { background: var(--accent); }

  .pf .legend .k-static::before { background: #cbd5e1; }

  @media (max-width: 480px) { .pf .block, .pf header.intro { padding: 16px; } }

</style>

<div class="pf" data-read lang="en">
  <header class="intro" id="top">
    <span class="eyebrow">Project results · November 2026</span>
    <h1>Forecasting and LLM-agent projects</h1>
    <p>Three projects built around one question: when does an LLM add value on top of a strong statistical model, and how do you measure that honestly? Two are pre-registered tests with point-in-time data and paired confidence intervals; the third is the live account those models feed.</p>
  </header>

  <nav class="tabs" role="tablist" aria-label="Projects">
    <button role="tab" data-tab="overview" aria-selected="true">Overview</button>
    <button role="tab" data-tab="weather" aria-selected="false">Weather forecast agent</button>
    <button role="tab" data-tab="epl" aria-selected="false">Premier League model</button>
    <button role="tab" data-tab="instagram" aria-selected="false">BoxScoreBrief on Instagram</button>
  </nav>

  <!-- ===================== OVERVIEW ===================== -->
  <section class="tab" id="overview" role="tabpanel">
    <div class="block">
      <h2>At a glance</h2>
      <div class="tablewrap">
        <table>
          <thead><tr><th>Project</th><th>Question</th><th>Headline result</th><th>Status</th></tr></thead>
          <tbody>
            <tr><td>Weather forecast agent</td><td class="wrap">Can a Claude agent reading NWS forecasters' notes beat statistical correction of weather models?</td>
              <td class="wrap">Rain: <span data-draw="ov-h4" data-source="coprimary" data-field="diff" data-where="test=H4">—</span> Brier vs baseline (better). Temperature: <span data-draw="ov-h1" data-source="coprimary" data-field="diff" data-where="test=H1">—</span> (worse).</td>
              <td>Holdout scored once, Nov 20</td></tr>
            <tr><td>Premier League model</td><td class="wrap">Does a Dixon-Coles goals model give better win/draw/loss probabilities than league base rates?</td>
              <td class="wrap">Ranked probability score <span data-draw="ov-epl-model" data-source="epl_backtest" data-field="model" data-where="metric=Ranked%20probability%20score">—</span> vs <span data-draw="ov-epl-base" data-source="epl_backtest" data-field="baseline" data-where="metric=Ranked%20probability%20score">—</span> on the untouched 2025-26 season.</td>
              <td>First picks locked Nov 22</td></tr>
            <tr><td>BoxScoreBrief on Instagram</td><td class="wrap">A live sports account where models feed AI-written posts behind a fact check.</td>
              <td class="wrap"><span data-draw="ov-ig-followers" data-source="ig_summary" data-field="value" data-where="metric=followers">—</span> followers; <span data-draw="ov-ig-posts" data-source="ig_summary" data-field="value" data-where="metric=posts">—</span> posts with insights; Reels average <span data-draw="ov-ig-ratio" data-source="ig_summary" data-field="value" data-where="metric=reel_vs_static">—</span> the reach of static posts.</td>
              <td>Live since Oct 12</td></tr>
          </tbody>
        </table>
      </div>
      <p class="note">Brier and ranked probability score measure probability error: lower is better. A negative difference means the system beat its baseline.</p>
    </div>
    <div class="block">
      <h2>What ties them together</h2>
      <ul class="plain">
        <li>Rules are written and committed before results exist: a frozen spec, a one-time holdout, and a dated change log for every amendment.</li>
        <li>Every data access is point in time: models and tools only see information published before each decision. In the weather benchmark, every tool call is also audited for leaks.</li>
        <li>Comparisons are paired on the same questions, with bootstrap confidence intervals, and negative results are reported as they came out.</li>
        <li>Each data source's terms are reviewed before use, and raw data is never republished; only aggregated results appear here.</li>
      </ul>
    </div>
  </section>

  <!-- ===================== WEATHER ===================== -->
  <section class="tab" id="weather" role="tabpanel" hidden>
    <div class="block intro">
      <span class="eyebrow">forecast-agent-bench · weather domain · <a href="https://github.com/jddormer19/forecast-agent-bench">GitHub</a></span>
      <h2>Can an LLM agent that reads forecasters' notes beat statistical forecasting?</h2>
      <p>At 6 AM local time, the agent answers two yes/no questions per station and day: will today's high reach its 1991-2020 normal, and will at least 0.01 in of rain fall? It is compared with a logistic correction of three weather models that matches or beats a calibrated version of NWS MOS guidance.</p>
      <div class="figures">
        <div class="figure"><span class="figure-value" data-draw="wf-temp" data-source="weather_facts" data-field="value" data-where="fact=Temperature%20questions">—</span><span class="figure-label">temperature questions</span></div>
        <div class="figure"><span class="figure-value" data-draw="wf-precip" data-source="weather_facts" data-field="value" data-where="fact=Precipitation%20questions">—</span><span class="figure-label">precipitation questions</span></div>
        <div class="figure"><span class="figure-value" data-draw="wf-primary" data-source="weather_facts" data-field="value" data-where="fact=Primary%20holdout%20questions">—</span><span class="figure-label">primary holdout questions (after the model's training cutoff)</span></div>
        <div class="figure"><span class="figure-value" data-draw="wf-answers" data-source="weather_facts" data-field="value" data-where="fact=LLM%20answers%20logged">—</span><span class="figure-label">LLM answers logged</span></div>
        <div class="figure"><span class="figure-value" data-draw="wf-spend" data-source="weather_facts" data-field="value" data-where="fact=API%20spend%20(USD)">—</span><span class="figure-label">total API spend</span></div>
      </div>
    </div>

    <div class="block">
      <h2>The two pre-registered tests</h2>
      <div class="verdicts">
        <div class="verdict" id="v-precip">
          <h3>Precipitation (H4)</h3>
          <span class="mark" data-draw="h4-mark">—</span>
          <span class="big num" data-draw="h4-diff" data-source="coprimary" data-field="diff" data-where="test=H4">—</span>
          <span class="note">Agent <span data-draw="h4-agent" data-source="coprimary" data-field="agent_brier" data-where="test=H4">—</span> vs baseline <span data-draw="h4-ssp" data-source="coprimary" data-field="ssp_brier" data-where="test=H4">—</span>. 95% CI <span data-draw="h4-ci">—</span>, p = <span data-draw="h4-p" data-source="coprimary" data-field="p_value" data-where="test=H4">—</span>, n = <span data-draw="h4-n" data-source="coprimary" data-field="n" data-where="test=H4">—</span>.</span>
        </div>
        <div class="verdict" id="v-temp">
          <h3>Temperature (H1)</h3>
          <span class="mark" data-draw="h1-mark">—</span>
          <span class="big num" data-draw="h1-diff" data-source="coprimary" data-field="diff" data-where="test=H1">—</span>
          <span class="note">Agent <span data-draw="h1-agent" data-source="coprimary" data-field="agent_brier" data-where="test=H1">—</span> vs baseline <span data-draw="h1-ssp" data-source="coprimary" data-field="ssp_brier" data-where="test=H1">—</span>. 95% CI <span data-draw="h1-ci">—</span>, p = <span data-draw="h1-p" data-source="coprimary" data-field="p_value" data-where="test=H1">—</span>, n = <span data-draw="h1-n" data-source="coprimary" data-field="n" data-where="test=H1">—</span>.</span>
        </div>
      </div>
      <p class="note">Brier difference from the baseline; negative means the agent was better. Date-block bootstrap, Holm correction across the two tests. Primary holdout Jul 1 to Nov 15, 2026.</p>
    </div>

    <div class="block" id="w-forest">
      <h2>Every system against the baseline</h2>
      <p class="note">Only "Agent, all tools" was pre-registered as primary. The other rows are exploratory comparisons on the same questions.</p>
      <div class="chart" data-draw="forest" data-source="systems"></div>
      <div class="tablewrap">
        <table data-source="systems" data-row-key="id">
          <thead><tr><th data-field="track">Question</th><th data-field="system">System</th><th class="r" data-field="brier">Brier</th><th class="r" data-field="skill">Skill</th><th class="r" data-field="minus_ssp">vs baseline</th><th class="r" data-field="ci_low">CI low</th><th class="r" data-field="ci_high">CI high</th></tr></thead>
          <tbody data-draw="systems-table"></tbody>
        </table>
      </div>
    </div>

    <div class="block" id="w-cost">
      <h2>Cost versus quality</h2>
      <p class="note">Haiku, Sonnet and Opus 5.5 on the same 100 primary questions per question type (exploratory). The dashed line is the baseline on those questions. Haiku's cost is the average over its full holdout run.</p>
      <div class="chart" data-draw="costq" data-source="cost_quality"></div>
    </div>

    <div class="block" id="w-why">
      <h2>Why the forecast discussions hurt temperature</h2>
      <p>When the discussion pushed a temperature forecast down (<span data-draw="down-n" data-source="pushes" data-field="n" data-where="direction=Pushed%20down">—</span> answers), the high still reached normal <b data-draw="down-wrong" data-source="pushes" data-field="went_wrong" data-where="direction=Pushed%20down">—</b> of the time. Upward pushes were wrong <span data-draw="up-wrong" data-source="pushes" data-field="went_wrong" data-where="direction=Pushed%20up">—</span> of the time.</p>
      <div class="cols">
        <div>
          <h3>Share of the harm by station</h3>
          <div class="chart" data-draw="harm" data-source="harm_by_station" style="min-height:270px"></div>
        </div>
        <div>
          <h3>Language in the agent's reasoning</h3>
          <div class="tablewrap">
            <table data-source="failure_modes" data-row-key="language">
              <thead><tr><th data-field="language">Language</th><th class="r" data-field="most_harmed">Most harmed</th><th class="r" data-field="most_helped">Most helped</th><th class="r" data-field="all">All</th></tr></thead>
              <tbody data-draw="modes-table"></tbody>
            </table>
          </div>
          <p class="note">Three patterns: area-wide "below normal" statements applied to a single airport; Los Angeles's routine marine layer read as news; and double counting, since forecasters write the discussion from the same models the baseline already uses. Exploratory, done after scoring.</p>
        </div>
      </div>
    </div>

    <div class="block" id="w-stations">
      <h2>Agent against the baseline, by station</h2>
      <p class="note">Agent minus baseline, 95% intervals. Colored where the interval excludes zero.</p>
      <div class="chart" data-draw="stations" data-source="stations" style="min-height:320px"></div>
    </div>

    <div class="block" id="w-method">
      <h2>How it was run</h2>
      <div class="cols">
        <div>
          <h3>Design</h3>
          <ul class="plain">
            <li>SPEC frozen before any download; precipitation track and amendments logged with what had been seen at the time.</li>
            <li>Primary holdout starts after the model's June 2026 training cutoff, so remembered weather can't explain the result.</li>
            <li>Ablations remove the discussion tool and the baseline tool; an extraction baseline tests whether the agent just copies stated numbers.</li>
            <li>Budget cap enforced in code from the API's token counts, with a file-locked spend ledger.</li>
          </ul>
        </div>
        <div>
          <h3>Data and leakage</h3>
          <ul class="plain">
            <li>Sources: NOAA ACIS and NWS products (public domain), Open-Meteo archived forecasts (CC BY 4.0), Iowa Environmental Mesonet archives. Downloads throttled to each provider's limits.</li>
            <li>Every row carries the time it became knowable; tools only see a snapshot as of 6 AM.</li>
            <li>The leak check failed on its first version, was diagnosed (repeated values, interpolated ECMWF hours) and fixed; it now passes for <span data-draw="wf-leak" data-source="weather_facts" data-field="value" data-where="fact=Leak%20check%20passed%20(model%2Fvariable%20pairs)">—</span> of 6 model and variable pairs.</li>
          </ul>
        </div>
      </div>
    </div>

    <div class="block" id="w-probe">
      <h2>Did the model just remember the weather?</h2>
      <div class="tablewrap">
        <table data-source="probe" data-row-key="id">
          <thead><tr><th data-field="track">Question</th><th data-field="period">Period</th><th class="r" data-field="n">n</th><th class="r" data-field="brier_no_tools">Brier, no tools</th><th class="r" data-field="brier_climatology">Brier, climatology</th></tr></thead>
          <tbody data-draw="probe-table"></tbody>
        </table>
      </div>
      <p class="note">With no tools or data, the model scores about as well as the historical average before and after its cutoff, so there is no sign that memorized weather explains the results.</p>
    </div>

    <details>
      <summary>Definitions</summary>
      <dl>
        <dt>Brier score</dt><dd>Mean squared error of a probability against what happened (0 or 1). Lower is better.</dd>
        <dt>Skill</dt><dd>1 minus Brier divided by climatology's Brier. 0 is no better than the historical average.</dd>
        <dt>SSP baseline</dt><dd>Simple statistical post-processing: logistic regression on three weather models' forecasts and recent observations, fitted on 2024-25.</dd>
        <dt>Agent, all tools</dt><dd>Claude Haiku 5.5 with 7 point-in-time data tools, including the NWS forecast discussion and the baseline's probability.</dd>
        <dt>Extraction baseline</dt><dd>One model call that only pulls the high or rain chance stated in the discussion, calibrated on dev.</dd>
      </dl>
    </details>
  </section>

  <!-- ===================== EPL ===================== -->
  <section class="tab" id="epl" role="tabpanel" hidden>
    <div class="block intro">
      <span class="eyebrow">epl-model · for BoxScoreBrief · code private while the first matchdays are scored</span>
      <h2>Win, draw and loss probabilities for Premier League matches</h2>
      <p>A Dixon-Coles goals model with time decay, trained on 14 seasons of public-domain results plus the current season from football-data.org. Picks are locked before kickoff, committed to git, and scored afterwards.</p>
    </div>
    <div class="block">
      <h2>Test season 2025-26</h2>
      <p class="note">Walk-forward: every round is predicted by a model fitted only on earlier matches. Time decay was chosen on 2024-25; 2025-26 was not used for any choice.</p>
      <div class="tablewrap">
        <table data-source="epl_backtest" data-row-key="metric">
          <thead><tr><th data-field="metric">Metric</th><th class="r" data-field="model">Model</th><th class="r" data-field="baseline">Baseline</th><th class="r">Better</th></tr></thead>
          <tbody data-draw="epl-bt-table"></tbody>
        </table>
      </div>
      <p class="note">Baseline is league base rates (home/draw/away frequencies); for accuracy it is "home team always wins". Picking the team higher in the table gets 47.9% right, so the model's edge is calibrated probabilities rather than picking winners.</p>
    </div>
    <div class="block cols">
      <div>
        <h3>Choosing the time decay (validation season 2024-25)</h3>
        <div class="chart" data-draw="epl-tuning" data-source="epl_tuning" style="min-height:200px"></div>
        <p class="note">Weighting recent matches more helps consistently. The chosen value sits at the edge of the grid; the grid was not widened after seeing the test season.</p>
      </div>
      <div>
        <h3>Locked picks</h3>
        <div class="tablewrap">
          <table data-source="epl_picks" data-row-key="id">
            <thead><tr><th data-field="match">Match</th><th data-field="kickoff_utc">Kickoff (CT)</th><th class="r" data-field="p_home">Home</th><th class="r" data-field="p_draw">Draw</th><th class="r" data-field="p_away">Away</th><th data-field="status">Result</th></tr></thead>
            <tbody data-draw="epl-picks-table"></tbody>
          </table>
        </div>
        <p class="note">Locked Nov 22 at 01:32 UTC, about 12.5 hours before the first kickoff. Football data provided by the Football-Data.org API; historical results from openfootball (CC0). Unofficial: not affiliated with the Premier League or any club. Model probabilities are not betting advice.</p>
      </div>
    </div>
  </section>

  <!-- ===================== INSTAGRAM ===================== -->
  <section class="tab" id="instagram" role="tabpanel" hidden>
    <div class="block intro">
      <span class="eyebrow"><a href="https://www.instagram.com/boxscorebrief/">@boxscorebrief</a> · <a href="https://github.com/jddormer19/boxscorebrief">case study on GitHub</a></span>
      <h2>A live sports account run by models and an LLM pipeline</h2>
      <p>My MLB, NFL and NBA models feed Claude-written captions behind a fact-check guardrail; an evaluation harness measures caption quality. Instagram insights are collected automatically every few hours.</p>
      <div class="figures">
        <div class="figure"><span class="figure-value" data-draw="ig-followers" data-source="ig_summary" data-field="value" data-where="metric=followers">—</span><span class="figure-label">followers</span></div>
        <div class="figure"><span class="figure-value" data-draw="ig-posts" data-source="ig_summary" data-field="value" data-where="metric=posts">—</span><span class="figure-label">posts with insights</span></div>
        <div class="figure"><span class="figure-value" data-draw="ig-reel" data-source="ig_summary" data-field="value" data-where="metric=reel_reach">—</span><span class="figure-label">average reach, Reels</span></div>
        <div class="figure"><span class="figure-value" data-draw="ig-static" data-source="ig_summary" data-field="value" data-where="metric=static_reach">—</span><span class="figure-label">average reach, static posts</span></div>
      </div>
    </div>
    <div class="block">
      <h2>Followers</h2>
      <div class="chart" data-draw="ig-followers-chart" data-source="ig_followers" style="min-height:220px"></div>
    </div>
    <div class="block">
      <h2>Average reach by post type</h2>
      <div class="legend"><span class="k-reel">Reel</span><span class="k-static">Static post</span></div>
      <div class="chart" data-draw="ig-kind-chart" data-source="ig_by_kind" style="min-height:300px"></div>
      <p class="note">Saves and shares are near zero across all post types; that is the engagement gap to work on.</p>
    </div>
  </section>
  <footer class="note" style="text-align:center;padding-top:8px">Jackson Dormer · <a href="https://github.com/jddormer19" style="color:inherit">github.com/jddormer19</a> · Results as of November 22, 2026</footer>
</div>

<script>

  // shared helpers

  window.pf = window.pf || {};

  pf.c = {accent: '#2563eb', muted: '#cbd5e1', good: '#15803d', bad: '#dc2626', grid: '#eef1f5', axis: '#cbd5e1', ref: '#94a3b8'};

  pf.f4 = d3.format('+.4f'); pf.p4 = d3.format('.4f'); pf.pct = d3.format('.0%'); pf.int = d3.format(',');

  pf.ok = (id) => { const d = dash.data(id); return d.status === 'ok' ? d.data : null; };

  pf.row = (id, key, val) => (pf.ok(id) || []).find((r) => String(r[key]) === val);

  pf.tip = (el) => {

    let t = el.querySelector(':scope > .tip');

    if (!t) { t = document.createElement('div'); t.className = 'tip'; t.hidden = true; el.appendChild(t); }

    return {

      show(ev, text) {

        t.textContent = text; t.hidden = false;

        const b = el.getBoundingClientRect();

        const x = Math.min(ev.clientX - b.left + 12, b.width - t.offsetWidth - 4), y = Math.min(ev.clientY - b.top + 12, b.height - t.offsetHeight - 4);

        t.style.left = Math.max(0, x) + 'px'; t.style.top = Math.max(0, y) + 'px';

      },

      hide() { t.hidden = true; },

    };

  };

  pf.ready = (el, ids) => {

    const st = ids.map((i) => dash.data(i).status);

    if (st.includes('error')) { el.replaceChildren(Object.assign(document.createElement('p'), {className: 'note', textContent: 'This chart could not load its data.'})); return false; }

    if (st.some((s) => s !== 'ok')) { el.replaceChildren(); return false; }

    return true;

  };

  pf.axis = (g) => { g.select('.domain').style('stroke', pf.c.axis); g.selectAll('line').style('stroke', pf.c.axis); };

  pf.put = (el, svg) => el.replaceChildren(svg.node(), el.querySelector(':scope > .tip') || '');

  pf.cell = (id, key, val, field, fmt) => (el) => { const r = pf.row(id, key, val); el.textContent = r ? fmt(r[field]) : '—'; };

  pf.tbody = (tb, rows, build) => tb.replaceChildren(...rows.map(build));

  pf.tr = (key, cells, rightFrom, cls) => {

    const tr = document.createElement('tr'); tr.dataset.key = key; if (cls) tr.className = cls;

    cells.forEach((c, i) => { const td = document.createElement('td'); td.textContent = c; if (i >= rightFrom) td.className = 'r'; tr.appendChild(td); });

    return tr;

  };



  dash.calc('ig_summary', {

    inputs: ['ig_followers', 'ig_by_kind'],

    title: 'Instagram summary',

    description: 'Latest follower count, posts with insights, and average reach of Reels vs static posts (weighted by posts).',

    fn: (followers, kinds) => {

      const latest = followers.length ? followers[followers.length - 1].followers : null;

      const sum = (f, pred) => kinds.filter(pred).reduce((s, k) => s + f(k), 0);

      const reel = (k) => k.format === 'Reel', stat = (k) => k.format !== 'Reel';

      const reelReach = sum((k) => k.avg_reach * k.posts, reel) / Math.max(1, sum((k) => k.posts, reel));

      const staticReach = sum((k) => k.avg_reach * k.posts, stat) / Math.max(1, sum((k) => k.posts, stat));

      return [{metric: 'followers', value: latest}, {metric: 'posts', value: sum((k) => k.posts, () => true)},

              {metric: 'reel_reach', value: Math.round(reelReach)}, {metric: 'static_reach', value: Math.round(10 * staticReach) / 10},

              {metric: 'reel_vs_static', value: Math.round(10 * reelReach / staticReach) / 10}];

    },

  });



  // tabs: switch sections by setting hidden and aria-selected

  pf.show = (name) => {

    const tabs = [...document.querySelectorAll('.pf nav.tabs button[data-tab]')];

    if (!tabs.some((b) => b.dataset.tab === name)) name = 'overview';

    tabs.forEach((b) => b.setAttribute('aria-selected', String(b.dataset.tab === name)));

    document.querySelectorAll('.pf section.tab').forEach((s) => { s.hidden = s.id !== name; });

    if (window.dash.redraw) window.dash.redraw();

  };

  document.querySelectorAll('.pf nav.tabs button[data-tab]').forEach((b) => b.addEventListener('click', () => { pf.show(b.dataset.tab); dash.setLink(b.dataset.tab); }));

  pf.show((location.hash || '').slice(1));

</script>

<script>

  // overview and headline numbers

  dash.draw('ov-h4', pf.cell('coprimary', 'test', 'H4', 'diff', pf.f4));

  dash.draw('ov-h1', pf.cell('coprimary', 'test', 'H1', 'diff', pf.f4));

  dash.draw('ov-epl-model', pf.cell('epl_backtest', 'metric', 'Ranked probability score', 'model', pf.p4));

  dash.draw('ov-epl-base', pf.cell('epl_backtest', 'metric', 'Ranked probability score', 'baseline', pf.p4));

  dash.draw('ov-ig-followers', pf.cell('ig_summary', 'metric', 'followers', 'value', pf.int));

  dash.draw('ov-ig-posts', pf.cell('ig_summary', 'metric', 'posts', 'value', pf.int));

  dash.draw('ov-ig-ratio', pf.cell('ig_summary', 'metric', 'reel_vs_static', 'value', (v) => `${v}x`));



  const wf = (name, fact, fmt) => dash.draw(name, pf.cell('weather_facts', 'fact', fact, 'value', fmt));

  wf('wf-temp', 'Temperature questions', pf.int); wf('wf-precip', 'Precipitation questions', pf.int);

  wf('wf-primary', 'Primary holdout questions', pf.int); wf('wf-answers', 'LLM answers logged', pf.int);

  wf('wf-spend', 'API spend (USD)', (v) => `$${d3.format('.2f')(v)}`); wf('wf-leak', 'Leak check passed (model/variable pairs)', String);



  for (const [h, p] of [['H1', 'h1'], ['H4', 'h4']]) {

    dash.draw(p + '-diff', pf.cell('coprimary', 'test', h, 'diff', pf.f4));

    dash.draw(p + '-agent', pf.cell('coprimary', 'test', h, 'agent_brier', pf.p4));

    dash.draw(p + '-ssp', pf.cell('coprimary', 'test', h, 'ssp_brier', pf.p4));

    dash.draw(p + '-p', pf.cell('coprimary', 'test', h, 'p_value', d3.format('.3f')));

    dash.draw(p + '-n', pf.cell('coprimary', 'test', h, 'n', pf.int));

    dash.draw(p + '-ci', (el) => { const r = pf.row('coprimary', 'test', h); el.textContent = r ? `${pf.f4(r.ci_low)} to ${pf.f4(r.ci_high)}` : '—'; });

    dash.draw(p + '-mark', (el) => {

      const r = pf.row('coprimary', 'test', h);

      el.textContent = r ? `${r.verdict}${r.holm_significant ? ', significant after Holm correction' : ''}` : '—';

      el.classList.toggle('good', !!r && r.verdict === 'Agent better');

      el.classList.toggle('bad', !!r && r.verdict === 'Agent worse');

    });

  }

  dash.draw('down-n', pf.cell('pushes', 'direction', 'Pushed down', 'n', pf.int));

  dash.draw('down-wrong', pf.cell('pushes', 'direction', 'Pushed down', 'went_wrong', pf.pct));

  dash.draw('up-wrong', pf.cell('pushes', 'direction', 'Pushed up', 'went_wrong', pf.pct));



  const ig = (name, metric) => dash.draw(name, pf.cell('ig_summary', 'metric', metric, 'value', pf.int));

  ig('ig-followers', 'followers'); ig('ig-posts', 'posts'); ig('ig-reel', 'reel_reach'); dash.draw('ig-static', pf.cell('ig_summary', 'metric', 'static_reach', 'value', (v) => v.toFixed(1)));

</script>

<script>

  // tables

  dash.draw('systems-table', (tb) => pf.tbody(tb, pf.ok('systems') || [], (r) => {

    const base = r.system === 'SSP baseline';

    return pf.tr(r.id, [r.track, r.system, pf.p4(r.brier), d3.format('.2f')(r.skill), base ? '—' : pf.f4(r.minus_ssp),

      base ? '' : pf.f4(r.ci_low), base ? '' : pf.f4(r.ci_high)], 2, r.pre_registered ? 'primary' : '');

  }));

  dash.draw('modes-table', (tb) => pf.tbody(tb, pf.ok('failure_modes') || [], (r) =>

    pf.tr(encodeURIComponent(r.language), [r.language, pf.pct(r.most_harmed), pf.pct(r.most_helped), pf.pct(r.all)], 1)));

  dash.draw('probe-table', (tb) => pf.tbody(tb, pf.ok('probe') || [], (r) =>

    pf.tr(r.id, [r.track, r.period, pf.int(r.n), pf.p4(r.brier_no_tools), pf.p4(r.brier_climatology)], 2)));

  dash.draw('epl-bt-table', (tb) => pf.tbody(tb, pf.ok('epl_backtest') || [], (r) => {

    const acc = r.metric === 'Accuracy', fmt = acc ? d3.format('.1%') : pf.p4;

    const better = r.lower_is_better ? r.model < r.baseline : r.model > r.baseline;

    return pf.tr(encodeURIComponent(r.metric), [r.metric, fmt(r.model), fmt(r.baseline), better ? 'Model' : 'Baseline'], 1);

  }));

  pf.ct = new Intl.DateTimeFormat('en-US', {timeZone: 'America/Chicago', weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit'});

  dash.draw('epl-picks-table', (tb) => pf.tbody(tb, pf.ok('epl_picks') || [], (r) =>

    pf.tr(r.id, [r.match, pf.ct.format(new Date(r.kickoff_utc)), pf.pct(r.p_home), pf.pct(r.p_draw), pf.pct(r.p_away),

      r.status === 'Final' ? `${r.score} (${r.actual === r.favoured ? 'favourite won' : 'upset'})` : r.status], 2)));

</script>

<script>

  // interval chart used by the weather and station charts: rows of [label, value, lo, hi], grouped

  pf.intervals = (el, groups, opts) => {

    const all = groups.flatMap((g) => g.rows);

    const W = el.clientWidth || 600, labelW = Math.min(opts.labelW || 180, W * 0.42), rowH = 26, headH = 26, axisH = 30;

    const H = groups.length * headH + all.length * rowH + axisH;

    const lo = d3.min(all, (r) => r.lo), hi = d3.max(all, (r) => r.hi), pad = (hi - lo) * 0.06 || 0.002;

    const x = d3.scaleLinear().domain([Math.min(lo - pad, -0.002), Math.max(hi + pad, 0.002)]).range([labelW, W - 12]);

    const svg = d3.create('svg').attr('width', '100%').attr('viewBox', `0 0 ${W} ${H}`).attr('role', 'img').attr('aria-label', opts.aria);

    const tip = pf.tip(el);

    let y = 0;

    for (const g of groups) {

      svg.append('text').attr('x', 0).attr('y', y + 18).attr('class', 'ink').style('font-weight', 600).text(g.title);

      const top = y + headH;

      svg.append('line').attr('x1', x(0)).attr('x2', x(0)).attr('y1', top).attr('y2', top + g.rows.length * rowH)

        .style('stroke', pf.c.ref).style('stroke-dasharray', '3 3');

      g.rows.forEach((r, i) => {

        const cy = top + i * rowH + rowH / 2;

        const sig = r.hi < 0 || r.lo > 0;

        const color = r.primary ? pf.c.accent : (opts.colorBySign && sig ? (r.v < 0 ? pf.c.good : pf.c.bad) : pf.c.muted);

        svg.append('text').attr('x', 0).attr('y', cy + 4).attr('class', r.primary ? 'ink' : null).style('font-weight', r.primary ? 600 : 400).text(r.label);

        const m = svg.append('g').attr('data-source', opts.source).attr('data-field', opts.field).attr('data-where', `${opts.key}=${encodeURIComponent(r.key)}`);

        m.append('line').attr('x1', x(r.lo)).attr('x2', x(r.hi)).attr('y1', cy).attr('y2', cy).style('stroke', color).style('stroke-width', r.primary ? 2 : 1.4);

        m.append('circle').attr('cx', x(r.v)).attr('cy', cy).attr('r', r.primary ? 4.5 : 3.5).style('fill', color);

        m.append('rect').attr('x', labelW).attr('y', cy - rowH / 2).attr('width', W - labelW).attr('height', rowH).style('fill', 'transparent')

          .on('pointermove', (ev) => tip.show(ev, `${g.title} · ${r.label}: ${pf.f4(r.v)} (95% CI ${pf.f4(r.lo)} to ${pf.f4(r.hi)})`))

          .on('pointerleave', () => tip.hide());

      });

      y = top + g.rows.length * rowH;

    }

    pf.axis(svg.append('g').attr('transform', `translate(0,${y + 4})`).call(d3.axisBottom(x).ticks(W < 480 ? 4 : 6).tickFormat(d3.format('+.3f'))));

    pf.put(el, svg);

  };



  dash.draw('forest', (el) => {

    if (!pf.ready(el, ['systems'])) return;

    const keep = ['Agent, all tools', 'Agent, no discussion', 'Agent, no baseline tool', 'NWS MOS-based', 'Extraction baseline'];

    const data = dash.data('systems').data;

    pf.intervals(el, ['Precipitation', 'Temperature'].map((t) => ({title: t, rows: keep.map((s) => data.find((r) => r.track === t && r.system === s)).filter(Boolean)

      .map((r) => ({key: r.id, label: r.system, v: r.minus_ssp, lo: r.ci_low, hi: r.ci_high, primary: r.pre_registered}))})),

      {source: 'systems', field: 'minus_ssp', key: 'id', aria: 'Brier difference from the baseline for each system'});

  });



  dash.draw('stations', (el) => {

    if (!pf.ready(el, ['stations'])) return;

    const data = dash.data('stations').data;

    const sids = [...new Set(data.map((r) => r.station))].sort();

    pf.intervals(el, ['Temperature', 'Precipitation'].map((t) => ({title: t, rows: sids.map((s) => data.find((r) => r.track === t && r.station === s)).filter(Boolean)

      .map((r) => ({key: r.id, label: r.station, v: r.diff, lo: r.ci_low, hi: r.ci_high}))})),

      {source: 'stations', field: 'diff', key: 'id', labelW: 60, colorBySign: true, aria: 'Agent minus baseline by station'});

  });

</script>

<script>

  // cost vs quality (log x), harm bars, EPL tuning, Instagram followers and reach

  dash.draw('costq', (el) => {

    if (!pf.ready(el, ['cost_quality'])) return;

    const rows = dash.data('cost_quality').data, tracks = ['Temperature', 'Precipitation'];

    const W = el.clientWidth || 600, side = W >= 560, pw = side ? (W - 32) / 2 : W, ph = 220;

    const H = side ? ph + 24 : 2 * (ph + 24);

    const svg = d3.create('svg').attr('width', '100%').attr('viewBox', `0 0 ${W} ${H}`).attr('role', 'img').attr('aria-label', 'Brier score against cost per 1,000 forecasts');

    const tip = pf.tip(el);

    tracks.forEach((t, k) => {

      const rs = rows.filter((r) => r.track === t); if (!rs.length) return;

      const ox = side ? k * (pw + 32) : 0, oy = side ? 0 : k * (ph + 24), m = {l: 48, r: 12, t: 26, b: 34};

      const ssp = rs[0].ssp_same_questions, vals = rs.map((r) => r.brier).concat(ssp), y0 = d3.min(vals), y1 = d3.max(vals), padY = (y1 - y0) * 0.3 + 0.002;

      const x = d3.scaleLog().domain([1, 150]).range([ox + m.l, ox + pw - m.r]);

      const y = d3.scaleLinear().domain([y0 - padY, y1 + padY]).range([oy + ph - m.b, oy + m.t]);

      svg.append('text').attr('x', ox).attr('y', oy + 14).attr('class', 'ink').style('font-weight', 600).text(t);

      pf.axis(svg.append('g').attr('transform', `translate(0,${oy + ph - m.b})`).call(d3.axisBottom(x).tickValues([1, 10, 100]).tickFormat((v) => `$${v}`)));

      pf.axis(svg.append('g').attr('transform', `translate(${ox + m.l},0)`).call(d3.axisLeft(y).ticks(4).tickFormat(d3.format('.3f'))));

      svg.append('text').attr('x', ox + (pw + m.l) / 2).attr('y', oy + ph - 2).attr('text-anchor', 'middle').text('$ per 1,000 forecasts');

      svg.append('line').attr('x1', x(1)).attr('x2', x(150)).attr('y1', y(ssp)).attr('y2', y(ssp)).style('stroke', pf.c.ref).style('stroke-dasharray', '4 3')

        .attr('data-source', 'cost_quality').attr('data-field', 'ssp_same_questions').attr('data-where', `id=${encodeURIComponent(rs[0].id)}`);

      svg.append('text').attr('x', x(1) + 4).attr('y', y(ssp) + (ssp < d3.min(rs, (r) => r.brier) ? 13 : -5)).text(`Baseline ${pf.p4(ssp)}`);

      [...rs].sort((a, b) => a.usd_per_1000 - b.usd_per_1000).forEach((r, i) => {

        const g = svg.append('g').attr('data-source', 'cost_quality').attr('data-field', 'brier').attr('data-where', `id=${encodeURIComponent(r.id)}`);

        g.append('circle').attr('cx', x(r.usd_per_1000)).attr('cy', y(r.brier)).attr('r', 4.5).style('fill', pf.c.accent);

        g.append('text').attr('x', x(r.usd_per_1000)).attr('y', y(r.brier) + (i % 2 ? -10 : 17)).attr('text-anchor', 'middle').attr('class', 'ink').text(`${r.model} ${pf.p4(r.brier)}`);

        g.append('circle').attr('cx', x(r.usd_per_1000)).attr('cy', y(r.brier)).attr('r', 14).style('fill', 'transparent')

          .on('pointermove', (ev) => tip.show(ev, `${t} · ${r.model}: Brier ${pf.p4(r.brier)}, $${d3.format('.2f')(r.usd_per_1000)} per 1,000`))

          .on('pointerleave', () => tip.hide());

      });

    });

    pf.put(el, svg);

  });



  pf.hbars = (el, rows, o) => {

    const W = el.clientWidth || 400, labelW = o.labelW || 50, rowH = 22, H = rows.length * rowH + 6;

    const x = d3.scaleLinear().domain([Math.min(0, d3.min(rows, (r) => r.v)), d3.max(rows, (r) => r.v)]).range([labelW, W - 56]);

    const svg = d3.create('svg').attr('width', '100%').attr('viewBox', `0 0 ${W} ${H}`).attr('role', 'img').attr('aria-label', o.aria);

    const tip = pf.tip(el);

    rows.forEach((r, i) => {

      const cy = i * rowH + rowH / 2, x0 = x(Math.min(0, r.v)), x1 = x(Math.max(0, r.v));

      svg.append('text').attr('x', 0).attr('y', cy + 4).attr('class', 'ink').text(r.label);

      const g = svg.append('g').attr('data-source', o.source).attr('data-field', o.field).attr('data-where', `${o.key}=${encodeURIComponent(r.key)}`);

      g.append('rect').attr('x', x0).attr('y', cy - 7).attr('width', Math.max(1, x1 - x0)).attr('height', 14).attr('rx', 2).style('fill', r.color);

      g.append('text').attr('x', x1 + 6).attr('y', cy + 4).text(o.fmt(r.v));

      g.append('rect').attr('x', 0).attr('y', cy - rowH / 2).attr('width', W).attr('height', rowH).style('fill', 'transparent')

        .on('pointermove', (ev) => tip.show(ev, r.tip)).on('pointerleave', () => tip.hide());

    });

    pf.put(el, svg);

  };



  dash.draw('harm', (el) => {

    if (!pf.ready(el, ['harm_by_station'])) return;

    const rows = [...dash.data('harm_by_station').data].sort((a, b) => b.share_of_harm - a.share_of_harm);

    pf.hbars(el, rows.map((r) => ({key: r.station, label: r.station, v: r.share_of_harm,

      color: r.share_of_harm > 0.3 ? pf.c.bad : pf.c.muted,

      tip: `${r.station}: ${pf.pct(r.share_of_harm)} of the harm (${d3.format('+.2f')(r.total_harm)} Brier over ${r.n} questions)`})),

      {source: 'harm_by_station', field: 'share_of_harm', key: 'station', fmt: pf.pct, aria: 'Share of the harm by station'});

  });



  dash.draw('ig-kind-chart', (el) => {

    if (!pf.ready(el, ['ig_by_kind'])) return;

    const rows = [...dash.data('ig_by_kind').data].sort((a, b) => b.avg_reach - a.avg_reach);

    pf.hbars(el, rows.map((r) => ({key: r.kind, label: r.kind.replace(/_/g, ' '), v: r.avg_reach,

      color: r.format === 'Reel' ? pf.c.accent : pf.c.muted,

      tip: `${r.kind}: ${d3.format('.0f')(r.avg_reach)} average reach over ${r.posts} posts (${r.saves} saves, ${r.shares} shares)`})),

      {source: 'ig_by_kind', field: 'avg_reach', key: 'kind', labelW: 120, fmt: d3.format('.0f'), aria: 'Average reach by post type'});

  });



  pf.line = (el, rows, o) => {

    const W = el.clientWidth || 500, H = o.height || 200, m = {l: 44, r: 30, t: 10, b: 26};

    const x = o.x.range([m.l, W - m.r]), y = d3.scaleLinear().domain(o.ydomain).nice().range([H - m.b, m.t]);

    const svg = d3.create('svg').attr('width', '100%').attr('viewBox', `0 0 ${W} ${H}`).attr('role', 'img').attr('aria-label', o.aria);

    y.ticks(4).forEach((t) => svg.append('line').attr('x1', m.l).attr('x2', W - m.r).attr('y1', y(t)).attr('y2', y(t)).style('stroke', pf.c.grid));

    pf.axis(svg.append('g').attr('transform', `translate(0,${H - m.b})`).call(o.xaxis(d3.axisBottom(x))));

    pf.axis(svg.append('g').attr('transform', `translate(${m.l},0)`).call(d3.axisLeft(y).ticks(4).tickFormat(o.yfmt)));

    const g = svg.append('g').attr('data-source', o.source);

    g.append('path').datum(rows).attr('d', d3.line().x((r) => x(o.xv(r))).y((r) => y(o.yv(r)))).style('fill', 'none').style('stroke', pf.c.accent).style('stroke-width', 1.8);

    rows.forEach((r, i) => {

      const hl = o.highlight ? o.highlight(r) : i === rows.length - 1;

      g.append('circle').attr('cx', x(o.xv(r))).attr('cy', y(o.yv(r))).attr('r', hl ? 4 : 2).style('fill', pf.c.accent)

        .attr('data-field', o.field).attr('data-where', `${o.key}=${encodeURIComponent(r[o.key])}`);

    });

    const last = rows.find((r) => (o.highlight ? o.highlight(r) : r === rows[rows.length - 1]));

    if (last) { const lx = x(o.xv(last)), end = lx > W - 140; svg.append('text').attr('x', end ? lx - 8 : lx + 6).attr('y', y(o.yv(last)) - 8).attr('text-anchor', end ? 'end' : 'start').attr('class', 'ink').text(o.label(last)); }

    const tip = pf.tip(el), bis = d3.bisector((r) => x(o.xv(r))).center;

    svg.append('rect').attr('x', m.l).attr('y', m.t).attr('width', W - m.l - m.r).attr('height', H - m.t - m.b).style('fill', 'transparent')

      .on('pointermove', (ev) => { const r = rows[bis(rows, d3.pointer(ev)[0])]; if (r) tip.show(ev, o.tip(r)); }).on('pointerleave', () => tip.hide());

    pf.put(el, svg);

  };



  dash.draw('ig-followers-chart', (el) => {

    if (!pf.ready(el, ['ig_followers'])) return;

    const rows = dash.data('ig_followers').data, parse = d3.utcParse('%Y-%m-%d'), fmt = d3.utcFormat('%b %-d');

    pf.line(el, rows, {x: d3.scaleUtc().domain(d3.extent(rows, (r) => parse(r.day))), xv: (r) => parse(r.day), yv: (r) => r.followers,

      ydomain: [0, d3.max(rows, (r) => r.followers)], xaxis: (a) => a.ticks((el.clientWidth || 500) < 480 ? 4 : 7).tickFormat(fmt), yfmt: pf.int,

      source: 'ig_followers', field: 'followers', key: 'day', label: (r) => `${pf.int(r.followers)} followers`,

      tip: (r) => `${fmt(parse(r.day))}: ${pf.int(r.followers)} followers, ${r.posts_total} posts`, aria: 'Followers per day'});

  });



  dash.draw('epl-tuning', (el) => {

    if (!pf.ready(el, ['epl_tuning'])) return;

    const rows = [...dash.data('epl_tuning').data].sort((a, b) => a.xi - b.xi);

    pf.line(el, rows, {x: d3.scaleLinear().domain(d3.extent(rows, (r) => r.xi)), xv: (r) => r.xi, yv: (r) => r.rps,

      ydomain: d3.extent(rows, (r) => r.rps), xaxis: (a) => a.tickValues(rows.map((r) => r.xi)).tickFormat(d3.format('.3f')), yfmt: d3.format('.3f'),

      source: 'epl_tuning', field: 'rps', key: 'xi', highlight: (r) => r.chosen, label: (r) => `chosen: ${pf.p4(r.rps)}`,

      tip: (r) => `time decay ${r.xi}: validation RPS ${pf.p4(r.rps)}${r.chosen ? ' (chosen)' : ''}`, aria: 'Validation RPS by time-decay setting', height: 190});

  });

</script>

<script>dash.load(["coprimary", "systems", "cost_quality", "stations", "harm_by_station", "pushes", "failure_modes", "probe", "epl_backtest", "epl_tuning", "epl_picks", "ig_by_kind", "ig_followers", "weather_facts"]);</script>
</body>
</html>