Part 01 / Topic 6 of 7
Writing clean experiment code
Experiments grow messy fast. Three habits keep them honest:
- Functions over copy-paste. One function per step (load, clean, train, evaluate) — then a change happens in one place.
- Constants at the top. Seed, test size, learning rate — visible and changeable, not buried.
- Print what matters. A result you did not print is a result you will re-run.
SEED = 42
TEST_SIZE = 0.2
def load_data():
...
def evaluate(model, X, y):
...
If you work in notebooks: keep them tidy by restarting the kernel and running top-to-bottom before trusting any number. Out-of-order cells are the classic source of "it worked yesterday".
Done here? The practice set for Part 1 — 4 exercises with solutions — is on the part page.