Module 5 · Data that arrives dirty

A feature table: one row per entity, as of a moment

In this lesson

  • 10 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 10 of 12 in this chapter

This chapter’s goalLoad an exported CSV with mixed encodings, ambiguous dates and duplicate rows into a typed, deduplicated table by re-runnable query with every dropped row counted, decide and document what each missing value means, and produce a feature table for a model in which no column knows anything that happened after its row’s timestamp.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
One row of a feature table, and which side of the moment each column comes fromas_of − 90dThe feature window opens. Orders from here onwards are countedas_of − 1dThe last order a feature is allowed to seeas_ofThe moment the question is asked. Nothing from here may enter a featureas_of + 1dThe label window opensas_of + 60dThe label window closes, and only now may this row be used for trainingRead the finished query and, for every column, say which side of as_of its data comes from. Everyfeature: before. The label: after. The last event is the one people forget, and forgetting it labelsevery recent customer as churned because their future has not happened yet.
Read the finished query and, for every column, say which side of as_of its data comes from. Every feature: before. The label: after. The last event is the one people forget, and forgetting it labels every recent customer as churned because their future has not happened yet.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The table a model is trained on has a very specific shape

One row per thing you are predicting about, at a moment in time. Every column except one is something you knew at that moment. The one exception is the label: what happened afterwards, which is what the model is learning to predict. This lesson builds that table in SQL, because most of the work of a model is this query, and most of the ways a model goes wrong are ways this query was wrong.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Building Apps with AI exam.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘A feature table: one row per entity, as of a moment’, in Data, SQL and Getting to the Answer. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/data-and-sql/building-a-feature-table (Accessed: 27 November 2026).