Skip to content

Framing: target, features and the moment of prediction

Most failed models were framed badly before any fitting began. Fix the unit, the moment of prediction, the target and the decision first.

Introductory ~11 min9 steps

You will be able to

  • Write a prediction problem as one sentence with a unit, a moment, a target and a decision
  • Reject features that aren't known at the moment of prediction
  • Use data characteristics to narrow what can work

Read first

01

One sentence before any model

Read

Write the problem as a sentence with four blanks:

For each customer, on the first day of the month, predict whether they cancel within 30 days, so we can offer a discount.

Unit: one row is one what? Moment: when is the prediction made? Target: what exactly counts as the answer, and how long until you know it? Decision: what changes because of the score?

If you can't fill in the last blank, a model won't help yet.

02

Which features survive?

Predict

Predict first

Using the sentence above, which of these features can you use?

Support tickets in the last 90 daysCancellation reason codeRefund issued this month
Reveal

Support tickets in the last 90 days. It's known on the first of the month. A cancellation reason exists only after canceling, and a refund issued later in the month is in the future. Both would score brilliantly in testing and fail in use, because they contain the answer.

03

The moment of prediction

Read

Picture one row on the day it would be scored. Every feature must hold the value it had then.

Warehouses often store the latest value. A customer's "total spend" or "plan" today isn't what it was on the day you'd have predicted. Rebuild features as of that moment, or you've handed the model the future.

The same goes for the target: if outcomes take 60 days to arrive, the most recent 60 days of rows have no reliable label yet.

04

See the damage

Explore

Here the pipeline includes a column recorded after the outcome. Read the cross-validated accuracy, then the accuracy on new data, where that column isn't yet known.

DExplorable · Leakage detective

Why does a model that scores brilliantly in testing fail on real data?

Read the pipeline on the left. Will its cross-validation score overstate real-world accuracy by more than 6 points?

How sure?

The pipeline

200
60
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Switch The pipeline to Pick features inside each fold to see the two numbers agree.

05

What the data allows

Read

Your data narrows the choice before you compare anything.

CharacteristicWhat it changes
RowsFew rows favor simple, regularized models
Features per rowMany features need penalties or selection
LabelsNo labels means discovering, not predicting
DependenceGroups and time change the split
RequirementsA needed explanation or fast score can overrule accuracy
06

Your own sentence

Reflect

Pick a prediction you would like to make at work. Write its sentence with all four blanks. Then name one column you'd be tempted to use that isn't known at the moment of prediction, and how long the target takes to arrive.

07

Check your understanding

Checkpoint

Check yourself

A hospital wants to predict readmission at the moment of discharge. Which feature can't it use?

Show the answer

Answer: c

Follow-up visits happen after the moment of prediction. Length of stay is known at discharge, so it's fine here, though it wouldn't be for a prediction made on admission.

Check yourself

Why write down the decision a model will support?

Show the answer

Answer: b

Missing a churner and bothering a loyal customer have different costs. Only the decision can tell you which matters more.

Check yourself

You have ten million support messages and no labels saying which are urgent. What does that change first?

Show the answer

Answer: a

Without a known outcome there's nothing to score predictions against. A small labeled sample, or a validated LLM labeler, is often the cheapest way in.

08

Set it up

In the app

In Predict, press New experiment, then fill in Target, such as {{target}}, and check the Task. Set Groups or Time order if your rows repeat or run through time. Under Features, read Left out automatically and the reason beside each column. Use anyway puts a column back, so make sure you can say why it's known in time.

09

Recap

Recap
  • Fill in unit, moment, target and decision before fitting anything.
  • A feature must hold the value it had at the moment of prediction.
  • The decision defines which errors matter. Rows, features, labels, dependence and requirements narrow what can work.

Concepts in this lesson