Prediction Problems: Target, Features, Prediction Time
Learning goal: define prediction unit, target, horizon, decision, and information available at prediction time.
Your manager says: "Let's predict next week's case volume for each service site." That sounds like a clear task, but a lot is still undefined: what does one "prediction" correspond to: one site, one day, or one shift? Is the target the raw case count, or a binary flag for exceeding capacity? When does "next week" actually start? Most importantly, at the moment you make the prediction, which fields do you really already know, and which only appear afterward?
Skipping this step and feeding data straight into a model has a familiar consequence: a team uses a column that is only produced after a case closes, the model looks great on historical data, but the moment it goes live the numbers do not match at all, because that column simply does not exist yet at prediction time. Writing down the prediction unit, the target, and the prediction time up front avoids this kind of after-the-fact, costly surprise.
A vague task description
"Predict case volume": no defined prediction unit, no target definition, no time horizon, and no check on which columns are actually available at prediction time.
A clearly framed prediction problem
- Prediction unit
- One row = one service site at a given split_time, producing one prediction case (case_id) for a future window.
- Target
- target_numeric is the future case volume (regression); target_binary is whether it exceeds a capacity threshold (classification).
- Prediction time
- Every case_id carries a split_time: only features_* that existed before that moment may be used to predict.
import pandas as pd
# clean: a service-demand prediction dataset, one row per prediction case
df = pd.read_csv("DS201_Service_Demand_Clean.csv", parse_dates=["created_at", "split_time"])
df.shape
df.dtypes
df[["case_id", "split_time", "target_numeric", "target_binary"]].head()
# Ask first: which features_* columns are actually known before split_time?
[c for c in df.columns if c.startswith("features_")]| Question | This dataset's answer |
|---|---|
| What is the prediction unit? | One case_id: one service site's demand prediction as of one split_time |
| What is the target? | target_numeric (future case volume) or target_binary (whether it exceeds a capacity threshold) |
| What is the decision? | Whether to pre-allocate staff or resources to that site |
| What is available at prediction time? | Only features_* produced before split_time; the target itself is never available at prediction time |
Suppose features_queue_length_at_split records the queue length at the moment of split_time, while features_total_handling_time records the total handling hours summed up after a case closes. The first already exists at prediction time and can be used as a feature; the second is only computable once the case has ended, so it is future information. Even if it correlates strongly with the target, it cannot be used.
- Treating 'prediction' as the same thing as 'analysis,' without first defining a clear prediction time
- Judging whether a column can be used purely from its name, instead of actually checking when it is produced
- Using the target's own historical values directly as a feature without checking whether it leaks the answer at prediction time
- Different people defining 'one prediction' inconsistently, which makes later evaluation results impossible to compare
Warning
Info
A colleague proposes using "the average handling time computed after a case closes" as a feature to predict "this week's case volume." What is the biggest problem with this?