Design a house-price prediction model
Two SigmaData Scientist · Technical ScreenLast updated
This problem evaluates your ability to design a robust end-to-end machine learning pipeline for house price prediction, focusing on data preprocessing, feature engineering, and validation strategy.
Scenario
You are tasked with building a regression model to predict the sale price of residential properties. You have access to a dataset containing 100,000 house sales over the past five years. Key features include square footage, number of bedrooms/bathrooms, year built, neighborhood (categorical), and the historical sale price.
Task
Design a machine learning pipeline to address the following requirements:
- Data Preprocessing: How would you handle missing values (e.g., missing basement area) and high-cardinality features like 'Neighborhood'?
- Feature Engineering: Propose three specific features you would derive to improve model performance, explaining the intuition behind each.
- Validation Strategy: Given that housing markets change over time, how would you split your data for training and testing to ensure the model generalizes to future market conditions?
- Metrics: Which evaluation metric would you choose to measure performance, and why might you prefer it over Mean Squared Error (MSE)?
Example Case
Suppose a new data point arrives: A house in an affluent, up-and-coming neighborhood with 2,500 sqft, built in 1990, with a missing value for the 'lot size' column. Briefly describe how your pipeline handles the missing lot size and the categorical neighborhood encoding before it reaches the model.
Constraints
- Assume the model must be interpretable for real estate agents.
- Be prepared to discuss how you would identify and treat outliers in the price distribution.
Hints
Hint 1
Consider how temporal leakage might occur if you use a simple random train-test split on time-series data.
Hint 2
For high-cardinality categorical features, think about methods beyond one-hot encoding, such as target encoding or embeddings.
Hint 3
Think about the difference between absolute error metrics like MAE and squared error metrics like MSE, especially regarding the impact of outliers on price prediction.
Follow-up questions
- How would you detect and account for 'data drift' where market trends shift significantly after your model is deployed?
- If the model shows high variance (overfitting), what specific regularization or architectural changes would you implement?
- How would you explain the impact of 'square footage' on the prediction to a non-technical stakeholder using model interpretability tools?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.