Week 2 · Saturday — build and investigate
Forecasting studio 2: reconcile the modelling table and draw the evaluation boundary
Project thread forecasting · linked lessons day 6, day 7, day 8, day 9, day 10
Milestone W2-a. Three pieces of work:
- a corrected, reconciled SQL query that produces one row per departure (target
bookings_finalplus the D-14 snapshot and the schedule and calendar features allowed by the contract); - a reusable set of data-quality checks with saved outputs;
- a provisional evaluation boundary that protects the final test period until Week 6.
- 90 minsession length
- 3timed blocks
- 5tasks
- —status
Session plan90 min
Before you start
Prepared before the session (under 3 minutes):
- The sample database at
python/artifacts/airline_sample.sqlite. Rebuild it if missing withcd python && uv run python -m capstone.airline_sim; it is the same seed-42 version as in Week 1. forecasting-project/with the dataset contract v0 and brief v1.- Lesson 7's join-grain example open for reference.
Nothing is pre-written for you. The queries, checks and boundary note are learner-authored.
Blocks3
Block 1: Recap and plan
15 minRe-read the dataset contract and brief v1 (5 min). Then answer, from memory, the question you carried in
decision-log.md. Write down how today's work will test it.Write today's plan in three lines:
- the columns that go into the modelling table, each with its contract verdict;
- the checks you will automate;
- the dates you propose for the evaluation boundary.
Any Week 1 carry-forward minimum is finished here first.
Block 2: Build - reconcile, check, bound
60 min- Minutes 0-10 - reproduce the fan-out (task
reproduce-fanout). See the wrong number before writing the right query. - Minutes 10-30 - the departure-level modelling table (task
model-table), reconciled againstflight_day. - Minutes 30-50 - automated quality checks (task
quality-checks). Make them a reusable script. Sunday runs the same script on a new feed. - Minutes 50-60 - provisional evaluation boundary (task
evaluation-boundary). Draw it before any model is fitted (Day 9).
- Minutes 0-10 - reproduce the fan-out (task
Block 3: Error analysis and record
15 minDo task
check-review. For each check, write the real-world defect it would catch, and what that defect would do to the D-14 feature or the target if nothing caught it.Then record in
decision-log.md:- the boundary decision;
- the reconciliation result;
- which check you trust least;
- the next unresolved question.
Tasks5
Task 1
codeRestrict to departures in 2023. Join
flight_daytobooking_curveon(date, flight_no)with no snapshot filter. For each month, report the row count andSUM(bookings_final)from the joined result, and fromflight_dayalone. Save the query assql/w02_fanout.sql.Task 2
codeWrite
sql/w02_model_d14.sql. It returns one row per departure, using only columns your contract allows at the D-14 cutoff plus the target:- keys:
date,flight_no,route,market; - calendar:
weekday,monthfromcalendar,holiday; capacity;bk_d14, thecumulative_bookingsatdays_to_departure = 14;- optionally
bk_d30, the same at 30 days, for Week 5; - the target
bookings_final.
Reconcile it with three checks:
- The row count equals
flight_day. SUM(bookings_final)by month equalsflight_day.bk_d14is never NULL.
- keys:
Task 3
codeImplement at least six checks as one script,
sql/w02_checks.sqlorsrc/checks.py. Each check returns the number of violating rows. Cover:- uniqueness of
(date, flight_no)and of(date, flight_no, days_to_departure); - every departure has exactly one D-14 snapshot;
- 13 snapshots per departure;
- no NULL keys or snapshot values;
- value ranges (no negative bookings);
cumulative_bookingsnever decreases asdays_to_departurefalls;bk_d14 <= bookings_final;- flight number and route format (upper case, no whitespace).
Save the output as a table: check | violating rows | threshold | action if violated.
- uniqueness of
Task 4
writingRecord a provisional evaluation boundary in
decision-log.md. The default is below; change it only with a written reason.- Protected final test: departures 2024-07-01 to 2024-12-31. Do not inspect, plot or summarize them until Week 6.
- Development: departures up to 2024-06-30.
- Validation window inside development: departures 2024-01-01 to 2024-06-30.
- Training: departures ending 2023-12-17, so there is a 14-day gap equal to the horizon.
Explain why the gap is needed. Note where the documented 2024-03-01 competitor-capacity step on IST-ADB, IST-AYT and IST-FRA falls. Add a code guard, for example an assertion that any development data frame has a maximum date of 2024-06-30 or earlier. Record row counts per partition.
Task 5
reviewFor each check, write one line: the real-world defect it would catch (for example a re-delivered snapshot, a renamed flight number or a missing feed day), and its effect on
bk_d14or the target if undetected. Name one defect that none of your checks would catch.
Rubric4 criteria
| Criterion | Meets | Exceeds |
|---|---|---|
| Reconciliation | The modelling table has exactly one row per departure. Row counts and monthly target sums match `flight_day`, and the fan-out is reproduced and explained. | Also reconciles the D-0 snapshot with `bookings_final`. Turns the reconciliations into reusable assertions rather than one-off queries. |
| Quality checks | At least six checks run, return violating-row counts, and have thresholds and actions. | The checks are parameterized by table name and dates, so they run unchanged on a new feed. They include a point-in-time check that needs a load timestamp, or the learner explains why it cannot be written yet. |
| Evaluation boundary | The protected test, the validation window and the 14-day gap are recorded with a reason and a code guard, before any model is fitted. | Explains which questions the validation window cannot answer (summer season, post-break stability) and how Week 5 backtesting will address them. |
| Point-in-time discipline | Only contract-approved columns are used. The snapshot filter is in the join. | Documents any "unclear" column left out and the evidence that would let it in. |
Required output
Saved in forecasting-project/:
sql/w02_fanout.sql;sql/w02_model_d14.sql, with the reconciliation output ("expected vs got");- the quality-check script and its saved output table;
- the evaluation-boundary note, with partition counts and the guard;
- a decision-log entry naming the next unresolved question.
Covers the Week 2 Saturday part of Appendix C: a reconciled join or aggregation, data-quality checks and a provisional evaluation boundary.
Studios are tracked separately from the 60 core lessons; completing one never completes a lesson.