7 routes42 sections324 units

Unit 1.1 · about 3 h

128 / 324

Unit 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.csv and day.csv define 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

  1. ML project checklist: framing and data capture
    Hands-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.

  2. Housing task statement as a prediction-context example
    Hands-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

  3. Instances, examples, and freshness requirements
    Rules 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

  4. Bike Sharing data dictionary and files
    UCI Bike Sharing Dataset

    Variables Table and Additional Variable Information: instant, dteday, hr, casual, registered, cnt, including the note that hr is absent from day.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 in day.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.csv weather 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

Closed-book, write the one-paragraph contract for hourly bike demand: unit (one system-hour), population (dated hours in 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.csv and day.csv can describe the same period at different grains and need different horizons and actions.
  • Reading dteday as a ready timestamp. In hour.csv it is a date string plus a separate hr column; 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.csv holds 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

  1. In the Housing Corp task, what is the unit of observation?

  2. Why do hour.csv and day.csv need separate prediction contracts?

  3. A bike feature table refreshes daily but predictions run hourly. What must the contract state?

  4. Where does the label horizon sit relative to prediction time in the bike contract?

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.

Mark passed, then open 1.2 Only mark this when you can do it without notes.

Leads to

Resources for this unit

  • Hands-On Machine Learning with Scikit-Learn and PyTorch - Chapters 1 and 2
    Aurelien Geron (O'Reilly, 2025)primarycourse
    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
    Google for Developerssupportapplication
    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
    UCI Machine Learning Repositorysupportpractice
    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
    scikit-learnrequiredreference
    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
    scikit-learnsupportreference
    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
    Google for Developerssupportapplication
    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.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels