Feature engineering and preprocessing · insight-0125
Express time features relative to the decision moment, not as absolute dates
- Evidence type
- practitioner heuristic
- Difficulty
- medium
- Roles
- Data scientist, ML engineer
- Industries
- aviation, saas
Summary: situation, action, reason, boundary
Situation
A model uses raw dates or timestamps as features, for example booking date or departure date as ordinal numbers.
Action
Derive features relative to the prediction time (days to departure, days since last purchase, age of account) plus calendar flags, and keep absolute time only for validation splits.
Reason
Relative quantities recur in future data, while absolute dates in the future are by definition outside the training range.
Boundary
Booking, churn, credit and maintenance models where events are timed relative to a decision.
Symptom or risk
The model learns the training period's calendar and extrapolates poorly; trees cannot predict beyond dates they have seen.
Exceptions
A deliberate trend term can be justified in a linear model when the trend is expected to continue and is monitored.
Trade-offs
Relative features lose information about regime changes; add explicit regime flags when a break is known.
Pitfalls
Measuring "days since" from a timestamp recorded after the decision, such as the final ticketing time.
Example
Synthetic booking_curve table: days_to_departure snapshots at 90, 60, ..., 0 are the natural feature axis, not the calendar date.
Lessons and concepts
Claims and their sources
Regression trees fit piecewise-constant functions over regions of the training data, so inputs beyond the training range fall into boundary regions (ESL section 9.2).