Unit 1.1 · about 3 h
128 / 324Unit of observation, prediction time and label horizon
Every later choice inherits the prediction context. A row is not a prediction; the contract that binds a row to a decision time is.
- explain
You can now
- State the unit of observation, the population, and the prediction context for a new problem in one short paragraph.
- Specify prediction time, feature cutoff, action time, label horizon, and label availability for an hourly bike-demand task.
- Explain why
hour.csvandday.csvdefine different prediction contexts even though they describe the same system.
Covers
- Unit of observation, population and prediction context
- Prediction time, feature cutoff, action time and label horizon
Study, in this order
4 steps
- ML project checklist: framing and data captureHands-On Machine Learning with Scikit-Learn and PyTorch - Chapters 1 and 2
Frame the problem and look at the big picture, items 1 to 12; Get the data, items 1 to 11, including item 11 on sampling a test set aside and never looking at it
Depth · Read as a checklist, not a textbook. Skip the Launch section here; it returns in the lineage unit.
- Housing task statement as a prediction-context exampleHands-On Machine Learning with Scikit-Learn and PyTorch - Chapters 1 and 2
Book Chapter 2: Frame the Problem (printed pp. 43-45). Notebook 02: Get the Data: the Housing Corp task statement, predicting median house values in Californian districts, where the unit of observation is one district
- Instances, examples, and freshness requirementsRules of Machine Learning - first controls
Terminology: Instance, Label, Feature, Feature Column, Example; Rule 8: Know the freshness requirements of your system, with the Play Search and Whats Hot staleness examples
- Bike Sharing data dictionary and filesUCI Bike Sharing Dataset
Variables Table and Additional Variable Information:
instant,dteday,hr,casual,registered,cnt, including the note thathris absent fromday.csv; Dataset Files:hour.csv,day.csv,Readme.txt; Dataset Characteristics with the no-missing-values statement
Focus on
- The unit of observation is the row the decision attaches to: one district in housing, one system-hour in
hour.csv, one system-day inday.csv. The two bike files are different populations of prediction contexts, not two views of one table. - Prediction time fixes which fields may be used. Anything recorded after the cutoff is unavailable even when it sits in the same CSV row: the horizon outcome itself, and also the weather observed during the hour. At the top of the hour a live system has only a forecast, so using
hour.csvweather is an oracle-forecast assumption the contract must declare. - Freshness is part of the context. State how old a model or feature may be before quality loss forces action, using Rule 8: Play Search degrades in under a month without updates, while identifier-free Whats Hot models export infrequently.
- Checklist items 1 to 12 plus Get-the-data item 11 are the contract skeleton: objective, usage, current workaround, framing, measure, alignment, minimum performance, assumptions, and one untouched test set.
Reproduce closed-book
hour.csv), prediction time (top of the hour, before that hour rentals are known), cutoff (fields timestamped at or before prediction time only), horizon (the coming hour cnt), and action (fleet rebalancing). State why day.csv needs a separate contract.Traps
- Treating each CSV row as a prediction without naming the decision time.
hour.csvandday.csvcan describe the same period at different grains and need different horizons and actions. - Reading
dtedayas a ready timestamp. Inhour.csvit is a date string plus a separatehrcolumn; the prediction instant is their combination, and parsing it is part of the contract. - Quoting the landing page count as the file count. The page states 17389 instances while the downloadable
hour.csvholds 17379 data rows by direct count; count the file you downloaded and record the date.
Practice
The section mini-project covers this: a one-page prediction contract with unit, prediction time, cutoff, horizon, and an availability table for the Bike Sharing rebuild.
Self-test
-
In the Housing Corp task, what is the unit of observation?
One Californian district, which is one row of the housing data. The model predicts one median house value per district. -
Why do
hour.csvandday.csvneed separate prediction contracts?Different units (hour versus day), different horizons (next-hour versus next-daycnt), and different availability:hrexists only inhour.csv, and an hourly rebalancing action cannot wait for the day aggregate. -
A bike feature table refreshes daily but predictions run hourly. What must the contract state?
The feature cutoff and the freshness requirement: hourly predictions reuse the last daily value, with a stated maximum age and a staleness check in the style of Rule 8. -
Where does the label horizon sit relative to prediction time in the bike contract?
After it:cntover the coming hour is realized after prediction time. The same-hourcasualandregisteredcounts are label parts, not features.
Completion criterion
Stop when
You can write the hourly bike contract from memory, including why day.csv is excluded and which columns are unavailable at prediction time.
Leads to
- 1.2 Targets, losses, metrics, decision rules and problem framing Turn the timed context into a target, loss, metric, and decision rule.
- 1.3 Split design, nested selection and test isolation Derive the split from the time and entity boundaries fixed here.
Resources for this unit
- Hands-On Machine Learning with Scikit-Learn and PyTorch - Chapters 1 and 2 Read Chapters 1 and 2 of the book, then run notebooks 01 and 02 and use ml-project-checklist.md for framing, data inspection, test-set creation, preprocessing pipelines, cross-validation, error analysis and persistence. Rebuild the workflow on UCI Bike Sharing with a chronological split and prohibit casual and registered when predicting cnt.
- Rules of Machine Learning - first controls Read Rules 1-5 and 8-9. Turn the existing heuristic into a baseline and test the feature path independently of the learner.
- UCI Bike Sharing Dataset Use hour.csv as the compact integrated dataset. Preserve a raw snapshot and data dictionary, split chronologically, and document why casual and registered are target proxies for cnt.
Also in this section
- scikit-learn - Common pitfalls and pipelines Read Common Pitfalls sections on inconsistent preprocessing and leakage, then Pipeline and ColumnTransformer. Seed global scaling, a target-derived feature and a partition duplicate, and make tests reject each defect.
- scikit-learn - Cross-validation splitters Use the group-aware and time-aware splitter sections plus GroupKFold and TimeSeriesSplit. Choose from the dependence structure and assert that no prohibited group or future timestamp crosses the boundary.
- Google ML Problem Framing - framing an ML problem Read Identify the output you need through Proxy labels and Define the success metrics, including the video-caching threshold analysis, the proxy-issue table, and both Check Your Understanding boxes.