Build a Housing Price Prediction Model from Historical Data
Company: Two Sigma
Role: Data Scientist
Category: Machine Learning
Difficulty: hard
Interview Round: Onsite
You are given a historical dataset of residential real-estate transactions — sale records with property attributes, location information, and sale dates spanning several years, including a period containing a major market shock (e.g., the COVID-19 pandemic). Build a model that predicts housing prices.
This is a discussion-driven modeling case. Walk the interviewer through the end-to-end process, and expect deep, sustained follow-up questions on every design choice: how you define the outcome and the features, which model you pick and why, how you evaluate it, how you handle data-quality problems, and how you keep the model working as the market changes.
### Constraints & Assumptions
- The dataset covers multiple years of transactions; some fields contain missing values.
- Records include property attributes (e.g., size, rooms, age, property type), location, and the transaction date. No fixed feature list is provided — proposing and justifying features is part of the exercise.
- The data window includes at least one market regime change (a shock such as COVID-19), so stationarity cannot be assumed.
- Predictions are produced in batch; there is no strict serving-latency requirement unless you decide otherwise.
- No coding is required, but you are expected to name concrete methods and, where relevant, write down formulas.
### Clarifying Questions to Ask
- Who consumes the predictions, and at what granularity — a price estimate for an individual home at listing time, a valuation of an existing portfolio, or a price index over regions?
- What exactly should the model predict: the price a home would fetch if sold today, or its price at some future date (a forecasting horizon)?
- What is the geographic scope, and how heterogeneous are the markets within it?
- Roughly how large is the dataset (number of transactions, years covered), and which fields have significant missingness?
- Are there interpretability requirements — does a stakeholder need to understand why the model prices a specific home the way it does?
- How will the model be refreshed — is periodic retraining allowed, and how quickly must it react to market moves?
### Part 1
Define the prediction target precisely and propose the feature set. How would you turn the raw transaction records into a supervised learning dataset?
```hint Target definition
Raw sale prices are strongly right-skewed and span orders of magnitude across markets. Consider modeling a **transformed** target — e.g., $\log(\text{price})$ or price per unit area — and be ready to say what the transformation does to your error metric.
```
```hint Leakage screening starts here
For every candidate feature, ask: "would this value actually be known at prediction time?" Fields generated *after* or *because of* the sale (e.g., a post-sale appraisal) cannot be features.
```
#### What This Part Should Cover
```premium-lock What This Part Should Cover
```
### Part 2
Choose a model family and defend it. Why might a non-linear model outperform linear regression on this data — what specifically about housing data makes it work? Then define your evaluation metrics and validation scheme.
```hint Why non-linear helps here
Housing data is full of **interactions** (the value of an extra bedroom depends on the neighborhood) and **threshold/saturation effects** (the tenth bathroom adds little). Tree ensembles capture these automatically; a linear model needs hand-built crosses.
```
```hint Validation with time-stamped data
Random K-fold lets the model train on 2023 sales and "predict" 2021 sales — it peeks into the future. Think about a **temporal split** (train on the past, validate on a later window) and what that changes about your reported error.
```
#### What This Part Should Cover
```premium-lock What This Part Should Cover
```
### Part 3
The dataset has missing values in several fields. How do you handle them? How do you perform feature selection, and how do you detect and prevent data leakage?
```hint Missingness is a signal
Before imputing, diagnose *why* a value is missing (missing completely at random vs. related to observed vs. unobserved values). A binary "was missing" indicator column is often informative, especially for tree models.
```
```hint The leakage smell test
A feature that is *suspiciously* predictive deserves an audit of **when** it is generated. Classic housing examples: tax assessments or appraisal values recorded after the sale, or fields only populated once a listing closes.
```
#### What This Part Should Cover
```premium-lock What This Part Should Cover
```
### Part 4
Housing markets move. After deployment, how do you detect data drift and variance drift? And how would your modeling approach have coped with a shock like COVID-19?
```hint Two different kinds of drift
Separate a shift in the **input distribution** $P(x)$ from a change in the **relationship** $P(y \mid x)$, and also from a change in noise level (variance). Each shows up in different monitors — feature distributions, residuals, and interval coverage — and each calls for a different response.
```
```hint Shock playbook
Throwing away all pre-shock history is rarely the best answer. Consider **recency weighting** or rolling windows, explicit **regime indicator** features, faster retraining cadence, and widening the communicated uncertainty until the new regime stabilizes.
```
#### What This Part Should Cover
```premium-lock What This Part Should Cover
```
### What a Strong Answer Covers
```premium-lock What a Strong Answer Covers
```
### Follow-up Questions
- Your non-linear model beats the linear baseline by a small margin. How do you decide whether the extra complexity is worth carrying in production? (Part 2)
- The model systematically underprices homes in one region. Walk through your debugging process step by step. (Parts 1 and 3)
- The business wants calibrated prediction intervals, not just point estimates. How do you produce and validate them?
- When would you argue for separate per-region models instead of one national model, and what are the costs of that choice? (Parts 2 and 4)
Quick Answer: This question evaluates a data scientist's competency in end-to-end supervised machine learning for real-estate pricing, focusing on precise outcome definition, feature engineering, handling missing and time-varying data, and robustness to market regime changes.