Skip to content
svgorigin-strip

Backtest origin strip

Which values does each backtest origin train on and forecast?

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

How to read it

  1. Read each strip as one backtest origin.
  2. The first part is what it trains on, the second what it forecasts and is scored on.
  3. Check that no forecast window comes before its training data.

Watch out

  • Origins that overlap heavily give fewer independent tests than their number suggests.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Positions come from the host's BacktestPlan (cs-ml backtest.rs): offsets from the end of the longest series.
  • A model never sees values after its origin; a sliding training window shows as a strip that starts later.
  • Origins closer together than the horizon forecast overlapping windows, so their errors are not independent.
# Backtest origin strip — Codesplash Chart Lab (recipe "origin-strip")
# controls: defaults
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"]

df = pd.read_csv("origin-strip-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
ORIGIN = "origin"
START = "train_start"
END = "train_end"
TEST = "test_end"
d = df.dropna(subset=[ORIGIN, END, TEST]).reset_index(drop=True)
start = d[START].fillna(0) if START else pd.Series(0, index=d.index)
y = np.arange(len(d))[::-1]
fig, ax = plt.subplots(figsize=(9, 0.5 * len(d) + 1.4))
ax.barh(y, d[END] - start, left=start, height=0.6, color=PALETTE[0], label="training")
ax.barh(y, d[TEST] - d[END], left=d[END], height=0.6, color=PALETTE[1], label="forecast and scored")
ax.set_yticks(y, d[ORIGIN])
ax.set_xlabel("position in the series")
ax.legend(fontsize=8, ncol=2, loc="upper center", bbox_to_anchor=(0.5, -0.18))
plt.show()

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