Skip to content
ML Academy

Feature engineering and preprocessing · insight-0123

Prefer splines to coarse bins when a linear model needs a nonlinear single-feature effect

Evidence type
practitioner heuristic
Difficulty
medium
Roles
Data scientist, Data analyst
Industries
insurance, aviation

Summary: situation, action, reason, boundary

  1. Situation

    You plan to cut days to departure or customer age into a few buckets so a linear model can bend.

  2. Action

    Use a spline basis (for example SplineTransformer) with a modest number of knots, regularize, and compare by cross-validation with bins and a tree baseline.

  3. Reason

    Splines fit smooth curves with few parameters and no artificial discontinuities, while bins throw away within-bucket variation.

  4. Boundary

    Linear, logistic and GLM models where curvature in a few inputs matters and interpretability is valued.

Symptom or risk

Effects jump at arbitrary cut points, nearby rows on either side get very different predictions, and bucket edges invite p-hacking.

Exceptions

Bins are right when the business acts on bands (fare buckets, age-based pricing rules) or when regulation requires simple tables.

Trade-offs

Splines are smoother but harder to describe in one sentence than a bucket table.

Pitfalls

Choosing bin edges using the target on the full dataset, which leaks and overfits.

Lessons and concepts

Claims and their sources