Skip to content
svgtraining-curves

Training curves

Is the network still learning, and when did it start to overfit?

Demo data · seed 20261101 · 180 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read each solid line as one network's training loss, epoch by epoch (or NGBoost's training score, round by round).
  2. Read the dashed line in the same colour as its loss on the held-back validation rows.
  3. Find the ring: the epoch with the lowest validation loss, whose weights early stopping keeps.
  1. Callout 1: Steep early fall: the network is learning the main pattern.
  2. Callout 2: Ring: the kept epoch.
  3. Callout 3: Dashed line rising while the solid one falls: overfitting.

Watch out

  • Training loss is measured with dropout on and validation loss with it off, so a validation curve below the training curve is not a bug.
  • A smooth fall on training rows says nothing about new data; read the run's cross-validated metrics.

Defaults

Loss axis
Linear
A log axis spreads out the late epochs, where losses change little.
Also: Log
Validation loss
On
Show the dashed validation curves and the kept epoch.

Pinned in the code

  • Draws the numbers the learner published (training history, member predictions, predicted densities); the chart computes nothing statistical.
  • Training loss is the mean over the epoch's mini-batches (with dropout on); validation loss is computed once per epoch on the held-out slice with dropout off, so the two are not on quite the same footing.
  • The ring marks the lowest validation loss — the weights early stopping keeps.
# Training curves — Codesplash Chart Lab (recipe "training-curves")
# controls: scale=linear, valid=true
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_MARKERS = ["o", "s", "^", "D", "P", "*", "2", "v"]

df = pd.read_csv("training-curves-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["network"] = pd.Categorical(df["network"].astype("string"), categories=["member 1", "member 2", "member 3"])

def levels_of(s):
    """Declared level order (categoricals), else order of first appearance."""
    if isinstance(s.dtype, pd.CategoricalDtype):
        return [v for v in s.cat.categories if (s == v).any()]
    return list(dict.fromkeys(s.dropna().astype(str)))
X = "epoch"
Y = "training log loss"
S = "network"
V = "validation log loss"
SHOW_VALID = True
series = levels_of(df[S]) if S else [None]
fig, ax = plt.subplots(figsize=(7, 4.2))
for i, s in enumerate(series):
    d = (df[df[S].astype(str) == s] if S else df).sort_values(X)
    colour = PALETTE[i % len(PALETTE)]
    many = len(series) > 1  # members share solid/dashed for train/validation, so a marker shape names each (as in the app)
    every = max(1, round(len(d) / 8))
    ax.plot(d[X], d[Y], color=colour, linewidth=1.6, marker=SERIES_MARKERS[i % 8] if many else None, markevery=((i * every) // len(series), every), markersize=4, label=s if s is not None else Y)
    if V and SHOW_VALID:
        dv = d.dropna(subset=[V])
        if len(dv):
            ax.plot(dv[X], dv[V], color=colour, linewidth=1.2, linestyle="--")
            best = dv.loc[dv[V].idxmin()]  # the epoch early stopping keeps
            ax.plot([best[X]], [best[V]], SERIES_MARKERS[i % 8] if many else "o", markerfacecolor="white", markeredgecolor=colour, markersize=6)
ax.set_xlabel(X)
ax.set_ylabel(Y)
ax.set_title("Training curves (dashed: validation)")
ax.legend(frameon=False, fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads training-curves-demo.csv · app theme from the optional codesplash helper