Build a baseline linear regression pipeline

Quick Overview

This interview question evaluates core ML concepts, assumptions, math intuition, training/evaluation trade-offs, and practical failure modes in a realistic interview setting. A strong answer for Build a baseline linear regression pipeline states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Build a baseline linear regression pipeline

Company: Citadel

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

Build a baseline linear regression pipeline in Python without code-completion tools: split the data into train/validation sets with a fixed random seed, impute missing values, one-hot encode categorical features, scale numeric features, train an ordinary least squares model, and evaluate it using RMSE and R^2 on the validation set while avoiding data leakage (fit transformers only on training data). Output the fitted coefficients, key metrics, and a brief interpretation of results.

Overview: This interview question evaluates core ML concepts, assumptions, math intuition, training/evaluation trade-offs, and practical failure modes in a realistic interview setting. A strong answer for Build a baseline linear regression pipeline states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

|Home/Machine Learning/Citadel
Citadel logo
Citadel
Aug 8, 2025
mediumData ScientistTechnical ScreenMachine Learning
11
0

Build a baseline linear regression pipeline

Task: Baseline Linear Regression Pipeline (Python)

Context

You are given a tabular dataset in a pandas DataFrame df. The goal is to predict a continuous target column target. Build a leakage-safe baseline linear regression pipeline and report performance and coefficients.

Requirements

  1. Split the data into train/validation sets (e.g., 80/20) using a fixed random seed.
  2. Avoid data leakage: fit imputers/encoders/scalers only on training data by using a single sklearn Pipeline.
  3. Preprocess features:
    • Impute missing values: median for numeric, most_frequent for categorical.
    • One-hot encode categorical features (drop one level to avoid multicollinearity; ignore unknown categories at validation).
    • Scale numeric features (standardization).
  4. Train an ordinary least squares linear regression model.
  5. Evaluate on the validation set using RMSE and R^2.
  6. Output:
    • Fitted coefficients with feature names (and intercept).
    • Key metrics (RMSE, R^2).
    • A brief interpretation of results.

Assumptions

  • DataFrame: df with target column named target; all remaining columns are features.

Deliverable

Provide clean, runnable Python code plus a short interpretation of the metrics and coefficients.

Clarifying Questions to Ask Guidance

  • 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 Guidance

  • 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 Guidance

  • 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?
Loading comments...