How do you handle a clearly non-linear relationship between X and Y when you must use a linear model?

Quick Overview

How to fit a clearly non-linear relationship between a feature and a target when the model has to stay linear. Tests whether you know what the linearity requirement constrains, how to choose model complexity without overfitting, and how to check that a fit works.

How do you handle a clearly non-linear relationship between X and Y when you must use a linear model?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

You plot the target Y against a feature X and the relationship is clearly non-linear, but the project requires a linear model. How do you handle this situation? ```hint What has to be linear Write a linear regression out as an equation and look at where the unknown quantities appear in it. ``` ```hint How much curve to allow Once you can add curved terms, think about how you would decide how many to add and how you would notice you added too many. ``` ### What a Strong Answer Covers - What the word "linear" constrains in a linear model, and what that means for the shapes it can fit - Concrete ways to bring curvature into the model and the shapes each one suits - Transforming the target, including how it changes coefficient interpretation and back-transformed predictions - How to choose the model's complexity and guard against overfitting - How to check that the transformation fixed the problem, and the cases no fixed transformation can handle ### Follow-up Questions - You fit the model on $\log Y$. How do you turn its predictions into estimates of the mean of Y on the original scale? - Why do high-degree polynomials behave badly near the edges of the data, and how do splines avoid that? - How would you choose the number and position of spline knots? - When would you argue that a linear model is the wrong tool for this data?

Overview: How to fit a clearly non-linear relationship between a feature and a target when the model has to stay linear. Tests whether you know what the linearity requirement constrains, how to choose model complexity without overfitting, and how to check that a fit works.

PracHub logo
General
Nov 24, 2026
mediumData ScientistOtherMachine Learning
0
0

You plot the target Y against a feature X and the relationship is clearly non-linear, but the project requires a linear model. How do you handle this situation?

What a Strong Answer Covers Guidance

  • What the word "linear" constrains in a linear model, and what that means for the shapes it can fit
  • Concrete ways to bring curvature into the model and the shapes each one suits
  • Transforming the target, including how it changes coefficient interpretation and back-transformed predictions
  • How to choose the model's complexity and guard against overfitting
  • How to check that the transformation fixed the problem, and the cases no fixed transformation can handle

Follow-up Questions Guidance

  • You fit the model on log⁡Y\log Y . How do you turn its predictions into estimates of the mean of Y on the original scale?
  • Why do high-degree polynomials behave badly near the edges of the data, and how do splines avoid that?
  • How would you choose the number and position of spline knots?
  • When would you argue that a linear model is the wrong tool for this data?