// Small hand-made SVG charts drawn from the real results (no chart library). export function BarBreakdown({ bars, max = 1, format = (v: number) => v.toFixed(2), label, }: { bars: { label: string; value: number; highlight?: boolean; note?: string }[]; max?: number; format?: (v: number) => string; label: string; }) { return (
{bars.map((b) => { const h = Math.max(6, (b.value / max) * 100); return (
{format(b.value)}
{b.label}
); })}
); } export function TrainingCurve({ log, val, }: { log: { step: number; loss: number; lr: number }[]; val: { field_f1: number; epoch: number }[]; }) { const W = 620; const H = 248; const pad = { l: 46, r: 16, t: 14, b: 50 }; const maxStep = Math.max(...log.map((d) => d.step)); const maxLoss = Math.ceil(Math.max(...log.map((d) => d.loss)) * 10) / 10; const x = (s: number) => pad.l + ((s - 1) / (maxStep - 1)) * (W - pad.l - pad.r); const y = (v: number) => pad.t + (1 - v / maxLoss) * (H - pad.t - pad.b); // light smoothing (moving average of 5 steps) so the trend is readable; raw loss is faint behind it const smooth = log.map((d, i) => { const win = log.slice(Math.max(0, i - 2), i + 3); return { step: d.step, loss: win.reduce((a, b) => a + b.loss, 0) / win.length }; }); const line = (pts: { step: number; loss: number }[]) => pts.map((d, i) => `${i ? "L" : "M"}${x(d.step).toFixed(1)},${y(d.loss).toFixed(1)}`).join(" "); const area = `${line(smooth)} L${x(maxStep)},${y(0)} L${x(1)},${y(0)} Z`; const ticks = [0, maxLoss / 2, maxLoss]; const epochStep = 100; return (
{ticks.map((t) => ( {t.toFixed(2)} ))} end of epoch 1 ยท checkpoint used {[1, 50, 100, 150].map((s) => ( {s} ))} optimizer step (8 receipts each)
Validation field F1 (30 receipts): {val.map((v) => ( epoch {v.epoch}: {v.field_f1.toFixed(2)} ))}
); }