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.
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
One sentence before any model
ReadWrite 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.
Which features survive?
PredictPredict first
Using the sentence above, which of these features can you use?
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.
The moment of prediction
ReadPicture 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.
See the damage
ExploreHere 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?
The pipeline
Commit your prediction above to see the result
Make your prediction to see the result.
Switch The pipeline to Pick features inside each fold to see the two numbers agree.
What the data allows
ReadYour data narrows the choice before you compare anything.
| Characteristic | What it changes |
|---|---|
| Rows | Few rows favor simple, regularized models |
| Features per row | Many features need penalties or selection |
| Labels | No labels means discovering, not predicting |
| Dependence | Groups and time change the split |
| Requirements | A needed explanation or fast score can overrule accuracy |
Your own sentence
ReflectPick 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.
Check your understanding
CheckpointCheck 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.
Set it up
In the appIn 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.
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