Components/LearningCurve

LearningCurve

Smoothed metric curves comparing training runs over steps.

VerifiedSince 0.8.0

Usage

Runs and Seeds

seeds draw as their mean inside a ± std band and smoothing sets the strength; wire a legend through v-model:hidden-runs and highlighted-run.

Loading demo...

Live Training

The curves grow with the data; a window resting on the last step follows training, and v-model:window reads and sets it.

Loading demo...

Log Step Axis

Pass a single-seed run as data; x-type="log" spreads out early training and leaves out step 0 and below.

Loading demo...

Best Practices

  • Compare algorithms with several seeds per run, and judge a gap against the band, not the means alone.
  • smoothing changes only the drawing; the tooltip lists the smoothed and the raw value.
  • Wire highlightedRun to legend hover and v-model:hidden-runs to legend clicks.
  • Localize labels: step writes the step in the tooltip title and the spoken reading.

API Reference

Props

PropTypeDefaultDescription
runsLearningCurveRun[]—Runs to compare.
smoothingnumber0.6Exponential-moving-average weight, 0–0.99; 0 draws the values as logged.
showRawbooleantrueDraws the raw values faintly under the smoothed line.
showBandbooleantrueDraws a ± one-standard-deviation band for multi-seed runs.
xType'linear' | 'log''linear'Step axis scale; log leaves out step 0 and below.
zoombooleantrueZooms and pans the step axis on the chart; false keeps the view fixed.
highlightedRunstring | null—Emphasizes one run and dims the rest.
xAxisNamestring—Step-axis title.
yAxisNamestring—Value-axis title.
yAxisNameGapnumber56Gap between the value axis and its name, in pixels.
xAxisTickFormat(step: number) => stringSI prefixesStep ticks; past a thousand steps they read 200k, 1.5M.
yAxisTickFormat(value: number) => string—Value ticks.
stepFormat(step: number) => stringGrouped digitsThe step in the tooltip and spoken reading.
tooltipValueFormat(value: number) => stringFour significant digitsValues in the tooltip and spoken reading.
heightnumber300Height in pixels.
widthnumberMeasuredExplicit width, for SSR and tests.
ariaDescriptionstring—Accessible description of the chart.
labelsPartial<LearningCurveLabels>EnglishAccessible name, key instructions and tooltip wording.
hiddenRunsstring[][]Names of runs left out of the chart and tooltip.
window[number, number] | nullnullStep window shown, bindable with v-model:window; null shows every step.

Events

EventPayloadDescription
update:hiddenRunshiddenRuns: string[]v-model:hidden-runs write-back.
update:windowwindow: [number, number] | nullAfter a zoom, a pan, a reset or following new data.

Types

EXAMPLE.TYPESCRIPT
interface LearningCurveRun {
  name: string                           // Tooltip name; hiddenRuns and highlightedRun refer to it
  data?: Array<[number, number]>         // [step, value] pairs of a single seed
  seeds?: Array<Array<[number, number]>> // Several seeds; takes precedence over data
  color?: string                         // Defaults to the categorical palette by position
}

interface LearningCurveLabels extends ChartLabels {
  step: (step: string) => string         // Tooltip title and spoken reading from the formatted step
  raw: string                            // Tooltip label in front of the raw value
}

// The same smoothing and aggregation, to precompute on a server
function smoothEma(values: readonly number[], weight: number): number[]
function aggregateSeeds(seeds: Array<Array<[number, number]>>, weight: number): RunCurve

interface RunCurve {
  steps: number[]
  raw: number[]                          // Mean of the seeds' raw values
  smoothed: number[]                     // Mean of the seeds' smoothed values
  spread: number[] | null                // Std of the smoothed values; null for a single seed
}

Interaction

InputResult
Hover, press and dragReads each run's smoothed value, band and raw value at the nearest step, and emphasizes the run nearest the pointer.
One-finger press and dragReads values; a vertical swipe still scrolls the page.
Drag across a rangeZooms into those steps.
Drag a zoomed chartPans, rubberbands past either end and glides on release; Shift-drag still brushes.
⌘/Ctrl + wheel, pinchZooms around the pointer.
Sideways trackpad swipePans a zoomed view.
Double-clickShows every step.
← / →, Home / EndReads step by step, jumps to either end.
+ / −, Shift + ← / →, 0Zooms, pans, shows every step.
EscapeClears the reading, or cancels a brush in progress.

Overview

  • Each seed is smoothed over its own steps, then read at the union of all seeds' steps: the curve is the mean of the smoothed values, the band their population standard deviation.
  • At a step only some seeds reach, the mean and band use only those seeds.
  • The value axis fits the smoothed lines, raw values and bands drawn in view, and springs to a new fit on a zoom, a pan, a hidden run or new data.
  • Readings snap to the nearest logged step; a keyboard reading has no pointer height and treats every run alike.
  • A window resting on the last step moves forward with new data; otherwise new data leaves the view alone.
  • Under prefers-reduced-motion: reduce the entrance, zoom and glide do not animate and the value axis lands at once.

Technologies

  • Smoothing matches TensorBoard's debiased exponential moving average, so the first steps are not dragged towards 0; past four points per plot pixel, each pixel column keeps its first, last, lowest and highest point.
  • Composed from the TxChart primitives; zoom and pan share one view layer with TxTimeseriesChart.
  • Source: packages/tuffex/packages/components/src/charts/src/learning-curve/.
View source
packages/tuffex/packages/components/src/charts/src/learning-curve/index.ts
  • TimeseriesChart: metrics over time, with the same zoom gestures.
  • Custom Chart: the same primitives, assembled into other charts.
  • Charts: the chart family and how to choose.