Day 209 — The dataset assembly, and the test that guards it

Wednesday, 3 March 2027 · Week 30 of 52 · Machine learning · Study day · 60 min

Four weeks of modelling run off one feature matrix, so an alignment error made today is an error in every result until day 238.

What you should be able to do tonight

  • Assemble a feature matrix with an explicit as-of date per row and no forward-filled values crossing an availability boundary.
  • Have a test that fails if any feature value in a row postdates that row’s as-of date.

Tasks 60 min

35 min Build qlib/ml/dataset.py: rows keyed by security and as-of date, features pulled through the store’s as-of interface, labels computed forward from the as-of date with the lag convention applied. Handle missingness explicitly with an indicator rather than imputing, because for most of these features missing is informative.

25 min Write the guard test: for a sample of rows, check every feature value against the store’s own availability timestamp and assert none postdates the row. Then rerun the day 155 poisoned-future test through the model pipeline rather than through the engine, since the model path is new and untested.

The running strategy

qlib/ml/dataset.py assembles the feature matrix through the store’s as-of interface with a test that no feature value postdates its row. The poisoned-future test now covers the model path as well as the engine.

Resources

Deliverable

qlib/ml/dataset.py with an as-of-safe feature matrix, and a passing guard test plus a model-path poisoning test.

Checkpoint

A feature is missing for 30 percent of your rows. What do you do, and why is imputation usually wrong here?

Prepare for tomorrow

Ten minutes tonight so Day 210, Thursday, 4 March 2027 starts clean. This is what the evening email sends you.

Reread the four validation schemes you now have and write one line each on what it estimates.

Check the arithmetic drill times; tomorrow is the thirtieth sitting.

Nothing to install.