Predicting House Prices in Ames, Iowa

This project predicts home sale prices using linear (ElasticNet) and non-linear (XGBoost) regression models trained on over 80 features. It incorporates robust preprocessing, feature engineering, and model tuning to achieve strong predictive accuracy.

The Dataset and the Goal

The data is the Ames Housing dataset, a record of roughly 2,900 residential sales in Ames, Iowa between 2006 and 2010. Each home is described by more than 80 features covering size, quality, location, and condition, ranging from square footage and year built to neighborhood, basement finish type, and kitchen quality. It is a well-known alternative to the older Boston housing data, and its appeal is that the features are messy in realistic ways: a mix of numeric, ordinal, and high-cardinality categorical columns, missing values that carry meaning rather than noise, and a handful of unusually large properties that distort any model fit with squared error.

The goal was to predict sale price from those features, and to do it with two different model families so the results could be compared: one regularized linear model and one gradient-boosted tree model. Performance was measured as RMSE between the natural logarithm of the predicted and actual sale price, evaluated across ten predefined train/test splits. Working in log space means the model is penalized for proportional error rather than absolute dollars, so missing on a $500,000 home by 10% costs the same as missing on a $100,000 home by 10%. Each split came with a fixed accuracy threshold that both models had to clear, 0.125 RMSE for the first five and 0.135 for the last five.

Data Exploration

I began by exploring the relationship between predictors and the response (home sale prices) to guide feature transformations and model selection. To get a feel for the data, I examined scatter plots, counted null values, and examined distributions of categorical and numerical variables. The interactive charts below highlight some of the more apparent patterns, such as the strong log-linear relationship between living area and sale price, and the ordinal impact of overall quality.

Correlation of Top 10 Features

Distribution of Log(Sale Price)

Log(Sale Price) by Overall Quality

Log(Sale Price) vs Living Area

Data Preprocessing

Model Tuning

Evaluation

ElasticNet Top Features

Figure: Top ElasticNet Features

XGBoost Top Features

Figure: Top XGBoost Features

Above are the most influential features for each model, aggregated across all folds. The linear ElasticNet model strongly emphasizes features we identified early in our data exploration, particularly living area and overall quality. In contrast, XGBoost appears to deprioritize the Overall_Qual categories entirely. Interestingly, only three features appear in the top 20 for both models: Year_Built, Gr_Liv_Area, and Total_Bsmt_SF. This aligns with our intuition that these features are key predictors of sale price, but also highlights the different ways linear and non-linear models can interpret feature importance.

Mean RMSE Scores:

0.121

ElasticNet

0.119

XGBoost

Technologies Used

Python Pandas NumPy Scikit-learn XGBoost
← Back to Portfolio

Contact Me

I'm always open to new opportunities and collaborations. Feel free to reach out via the links below!