When would you use spline features instead of polynomial features to model a non-linear relationship?

Quick Overview

Asks when spline features fit a non-linear relationship better than polynomial features in a linear model or GLM. Tests understanding of global versus local bases, behavior at the data boundaries, numerical conditioning, knot choice and cyclical features.

When would you use spline features instead of polynomial features to model a non-linear relationship?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

You are fitting a linear model or GLM and one input has a clearly non-linear effect on the target. When would you use spline features instead of polynomial features to model a non-linear relationship? ```hint Change one region If the data change only in one narrow range of the input, which coefficients of a polynomial fit move, and how far along the input does the effect reach? ``` ```hint Look at the edges Think about what a degree-10 polynomial does near the ends of the training range and just beyond it. ``` ### What a Strong Answer Covers - Why polynomial features form a global basis, and what that does to a fit that needs a local bend. - Behavior near the boundaries of the data and when extrapolating. - Numerical conditioning of raw polynomial columns. - How splines control flexibility, and the options for edges and cyclical features. - When polynomial features are still the better choice, and which model families the choice matters for. ### Follow-up Questions - How would you choose the number and placement of knots? - How would you encode hour of day so that 23:00 and 00:00 are treated as close? - How would you model an interaction between two non-linear features with splines? - Why do gradient-boosted trees rarely need spline features?

Overview: Asks when spline features fit a non-linear relationship better than polynomial features in a linear model or GLM. Tests understanding of global versus local bases, behavior at the data boundaries, numerical conditioning, knot choice and cyclical features.

Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

You are fitting a linear model or GLM and one input has a clearly non-linear effect on the target. When would you use spline features instead of polynomial features to model a non-linear relationship?

What a Strong Answer Covers Guidance

  • Why polynomial features form a global basis, and what that does to a fit that needs a local bend.
  • Behavior near the boundaries of the data and when extrapolating.
  • Numerical conditioning of raw polynomial columns.
  • How splines control flexibility, and the options for edges and cyclical features.
  • When polynomial features are still the better choice, and which model families the choice matters for.

Follow-up Questions Guidance

  • How would you choose the number and placement of knots?
  • How would you encode hour of day so that 23:00 and 00:00 are treated as close?
  • How would you model an interaction between two non-linear features with splines?
  • Why do gradient-boosted trees rarely need spline features?