ml-research-template · interactive walkthrough

Anatomy of an ML experiment, one line at a time

A real project, a real dataset, real outputs. Scroll — each card lights up the exact lines of code doing the work.

UCI wine quality · 1,599 rows laptop CPU · seconds/epoch result 0.621 ± 0.038 (5 seeds)
scroll ↓
STEP 1 / 4

Generate the project

One command generates the project. Nothing here is hand-written yet.

the command

One command

Copier asks ~8 prompts (name, Python, PyTorch or JAX, tracker…) and writes a working project. --trust lets it run git init + uv sync for you.

what you get

It arrives ready to run

Dependencies locked, git initialized, pre-commit hooks installed. The printed commands are the whole quickstart.

the map

Five files are yours

Configs, data, model, presets, loss — green files are the ones you'll ever edit. copier update never overwrites them.

the machinery

The rest is template-owned

The training loop, eval, checkpointing, resume — purple files are updated by copier update; you don't edit them.

smoke test

It trains before you touch anything

Two epochs on synthetic data verifies the install, config parsing, training loop, and checkpointing before any of your code is involved.

Bringing your own data changes two files.

STEP 2 / 4

Wire in the data

The entry points never change. You describe the data, then load it.

configs.py

Describe the dataset, typed

Six fields say everything train.py needs to know. Pydantic validates them; typos in a flag die before training starts.

configs.py

Every field is a CLI flag

Because csv_path is a config field, it can be set from the command line (data.csv_path=…) and is recorded in every run's config snapshot.

configs.py

The model sizes itself to the data

ModelConfig leaves n_features/n_classes as None — they're filled from DataConfig…

configs.py

…by one plain function

resolved() copies them over. This replaces YAML interpolation syntax — it's ordinary Python you can step through in a debugger.

datamodule.py

Download once, then read locally

The first run fetches 84 KB from UCI and saves it to cfg.csv_path. Later runs and tests read the local file.

datamodule.py

Four lines of preprocessing

Load the CSV, standardize each feature, shift labels 3–8 to 0–5. That's all the preparation this dataset needs.

datamodule.py

The seam

create_dataloaders(cfg, seed) is all train.py and eval.py ever call. Swap the dataset class inside it and the rest of the system doesn't notice.

That was the only code change. The rest is running commands.

STEP 3 / 4

Train & evaluate

What the console output tells you, line by line.

the run

Overrides are just key=value

No YAML edit needed for a one-off: any config field is addressable from the CLI, Hydra-style.

provenance

The provenance snapshot

config.yaml stores the resolved config, the git SHA, and the exact command — everything needed to reproduce this run later.

training

One line per epoch

55% accuracy after the first epoch on a laptop CPU. Early stopping (patience) ends the run if validation loss stops improving.

the footer

Checkpoints + a command to paste

best.ckpt and last.ckpt are written every epoch; the evaluate line is ready to run as-is.

eval

Eval restores the run's settings

It reads the snapshot next to the checkpoint — data path, model size, loss — so the numbers match training exactly: 0.9350 / 0.6489.

experiments.py

Name the winning settings

The settings worth keeping become experiment=wine — a preset in version control, so the result traces to a commit.

One seed is an anecdote. Five seeds is a claim.

STEP 4 / 4

Prove it

Turn one result into a number you can put in a paper.

multi-seed

Same script, five seeds

run_seeds.sh just loops train.py seed=… into one results directory. On SLURM the same thing is a job array.

aggregate

Mean, spread, interval

The aggregator reads each seed's metrics.json and bootstraps a 95% CI — 10,000 resamples of the 5-seed mean.

what the CI shows

Why one seed isn't enough

Seed 42 alone would have reported 0.677; seed 456, 0.571. The band is the range the five seeds actually support.

the paper line

0.621 ± 0.038 (5 seeds)

That's what goes in the table. To compare against a baseline, run it with the same seeds and pass --baseline for a paired test and effect size.