Design features for house price prediction
Two SigmaData Scientist · Technical ScreenLast updated
This question tests your ability to engineer features from heterogeneous tabular data, handle missing values, and select appropriate evaluation metrics for a high-stakes regression problem.
Problem Statement
You are tasked with building a predictive model for residential real estate prices in a major metropolitan area. You have access to a dataset containing 500,000 records, each representing a property sale from the last five years.
Data Schema
price: Target variable (USD).square_footage: Float.year_built: Integer.zip_code: Categorical.num_bedrooms,num_bathrooms: Integers.last_renovated_date: Date or null.nearby_amenities_list: List of strings (e.g., 'school', 'park', 'transit_hub').
Your Tasks
- Feature Engineering: Propose at least three specific features you would derive from the provided columns to improve model predictive power. Explain the intuition behind each.
- Preprocessing Strategy: How would you handle the missing values in
last_renovated_date? Justify your choice. - Evaluation: If the business goal is to minimize the relative impact of errors on both cheap and expensive homes, which loss function or evaluation metric would you prioritize (e.g., MAE, MSE, MAPE, or RMSLE)?
Considerations
- How would you handle the high cardinality of the
zip_codefeature? - Discuss the trade-off between using a linear model vs. a Gradient Boosted Decision Tree (GBDT) for this dataset.
Hints
Hint 1
Consider creating features that represent the age of the building relative to the time of sale rather than just the construction year.
Hint 2
For the 'last_renovated_date' column, think about whether a missing value represents a 'never renovated' state or a data quality issue.
Hint 3
When evaluating models where home prices can range from $50,000 to $10,000,000, consider how logarithmic transformations affect your error metric.
Follow-up questions
- How would you address potential data leakage if the 'last_renovated_date' is updated based on info found during the sale process?
- If you have to deploy this model to a low-latency API, what strategies would you use to reduce the size or inference time of your GBDT model?
- How would you incorporate external macro-economic data, such as interest rates or unemployment rates, into this model?
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.