Feature engineering and preprocessing · insight-0118
Add explicit interaction terms to a linear model when the effect of one driver depends on another
- Evidence type
- practitioner heuristic
- Difficulty
- medium
- Roles
- Data scientist, Data analyst
- Industries
- aviation, retail
Summary: situation, action, reason, boundary
Situation
Domain knowledge says an effect varies by context, for example price sensitivity that differs between short-haul and long-haul markets.
Action
Add a small number of domain-motivated products (price x market, days-to-departure x holiday) and compare by cross-validation against the main-effects model and a tree baseline.
Reason
Linear models are additive in their inputs, so they cannot represent effect modification unless a product term or segment split is supplied.
Boundary
Linear and logistic regression, GLMs and other additive models used for interpretability.
Symptom or risk
A linear model fits one average slope; residuals show opposite patterns by segment and the model misprices both.
Exceptions
Tree ensembles learn interactions from splits; hand-built products rarely help them much.
Trade-offs
Each interaction adds parameters and makes coefficients harder to explain; regularize when there are many.
Pitfalls
Interpreting a main-effect coefficient as the overall effect after adding its interaction; it is now the effect at the reference level.
Example
Synthetic airline simulator: true elasticities range from -0.6 to -1.35 by route, so one shared price slope must be wrong somewhere.
Lessons and concepts
Claims and their sources
PolynomialFeatures can generate interaction-only terms such as X1X2, while SplineTransformer works per feature and produces no interactions.