Scenario
Onsite machine-learning exercise: your task is to build a regression model using only numerical features that not only fits training data but also keeps low error when test points fall outside the feature ranges seen during training (i.e., extrapolation).
Task
-
Design and implement a regression solution that extrapolates robustly beyond the training feature range.
-
Provide code for:
-
Data splitting that explicitly creates an out-of-range (OOR) test subset.
-
A training pipeline with feature engineering, model choice, and regularization.
-
An evaluation protocol that reports performance in-range vs. out-of-range.
-
Explain your design decisions: feature engineering, model selection, regularization, and extrapolation evaluation methodology.
Assumptions
-
You are given a tabular dataset with numerical features X (shape: n_samples × n_features) and a continuous target y.
-
If no dataset is provided, you may demonstrate with a synthetic dataset and keep the same code path.
Requirements
-
Use models that can extrapolate (e.g., linear models, low-degree polynomial bases with regularization, or spline bases with linear extrapolation).
-
Standardize features appropriately.
-
Regularize to control coefficient growth outside the training range.
-
Hold out a test split drawn from an expanded feature range and report separate metrics for in-range (IR) and out-of-range (OOR) points.
Hints
-
Consider linear or monotonic models, polynomial basis with regularization, data standardization, and a hold-out test split drawn from an expanded feature range.
-
Tree ensembles without additional structure typically do not extrapolate.
Constraints & Assumptions
-
Preserve the scope, facts, inputs, and requested outputs from the prompt above.
-
If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it.
-
Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate.
Clarifying Questions to Ask
-
Clarify the task, data shape, labels, constraints, and evaluation metric.
-
State assumptions behind the math or modeling technique you choose.
-
Connect theory to practical training, debugging, and deployment implications.
What a Strong Answer Covers
-
Correct definitions and formulas where the prompt requires them.
-
A practical explanation of how the method behaves on real data.
-
Trade-offs, failure modes, diagnostics, and mitigation strategies.
-
Evaluation choices that match the product or modeling objective.
Follow-up Questions
-
How would noisy labels, class imbalance, or distribution shift affect the answer?
-
What would you monitor after deployment?
-
Which baseline would you compare against first?