Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
43,195 changes: 21,598 additions & 21,597 deletions data/regression_data.csv

Large diffs are not rendered by default.

21,597 changes: 21,597 additions & 0 deletions data/regression_data_draft.csv

Large diffs are not rendered by default.

13,988 changes: 13,988 additions & 0 deletions notebooks/ML_MiniProject_1.ipynb

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions project_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Real Estate Price Prediction Project

![Project Banner](https://education-team-2020.s3-eu-west-1.amazonaws.com/data-analytics/project+banners/real-state-project.jpg)

## Overview
This project builds a machine learning model to predict house prices in King County, Washington based on property features. As a data scientist at a real estate firm, I developed a solution that:
- Processes 21,597 property records
- Identifies key price drivers through feature engineering
- Delivers predictions with $129,696 average error
- Provides actionable insights for business strategy

**Key Skills Demonstrated**: Python, Pandas, Scikit-Learn, Feature Engineering, Hyperparameter Tuning, Model Evaluation

## Dataset
Historic home sales (May 2014 - May 2015) with 21 features including:
- `price`: Target variable (sale price)
- `sqft_living`: Living area square footage
- `zipcode`: Location identifier
- `yr_built`: Year built
- `waterfront`: Waterfront view (binary)
- Full feature list available in `data/` directory

## Project Steps

### 1. Data Cleaning & Transformation
- Fixed temporal inconsistencies (e.g., houses "renovated after sale")
- Handled price outliers ($100K-$8M range) with log transformation
- Removed redundant features (e.g., `sqft_above` vs `sqft_living`)

```python
# Fix illogical renovations
df['yr_renovated'] = np.where(df['yr_renovated'] > df['sale_year'], 0, df['yr_renovated'])
```

### 2. Feature Engineering
Created 5 new predictive features:
1. `house_age`: 2024 - `yr_built`
2. `was_renovated`: Binary renovation flag
3. `zipcode_avg_price`: Neighborhood price baseline (*train-set only*)
4. `years_since_renov`: Years since last renovation
5. `price_to_zip_ratio`: Premium/discount vs neighborhood

### 3. Modeling & Evaluation
Tested 4 regression models:
| Model | Test R² | Test RMSE |
|--------------------|---------|-------------|
| Linear Regression | 0.73 | $210,000 |
| Ridge Regression | 0.73 | $209,800 |
| **Random Forest** | **0.89**| **$129,696**|
| Gradient Boosting | 0.87 | $135,400 |

### 4. Hyperparameter Tuning
Optimized Random Forest with GridSearchCV (108 combinations):
```python
best_params = {
'n_estimators': 500,
'max_features': 'sqrt',
'min_samples_split': 2,
'min_samples_leaf': 1,
'max_depth': None
}
```
Achieved +0.002 R² gain at $21K RMSE tradeoff

## Key Findings

### Top Price Drivers
1. **Location (ZIP Code)**: 45.3% impact
2. **Living Area Size**: 34.5% impact
3. **Geographic Coordinates**: 8.9% impact
4. **House Age**: 1.9% impact
5. **Waterfront View**: 0.9% impact

**Surprising Insight**: Renovation timing (`years_since_renov`) showed <1% impact - buyers value location more than updates!

### Business Recommendations
- Prioritize properties in premium ZIP codes over renovation projects
- Use model to identify undervalued homes in emerging neighborhoods
- Allocate 80% of improvement budget to feature engineering vs model tuning


## File Structure
```
├── data/ # Original datasets
├── notebooks/ # Jupyter notebooks
│ └── Real_Estate_Price_Prediction.ipynb
├── visualizations/ # Generated plots
├── README.md # This document
```

## Dependencies
- Python 3.12+
- Pandas, NumPy
- Scikit-Learn, XGBoost
- Matplotlib, Seaborn
- Jupyter Notebook

---

**Presentation Summary**: [Download Slides](link_to_presentation.pdf)
**Final Model**: Random Forest Regressor (Test RMSE: $129,696)
Binary file added visualizations/feature_importances.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added visualizations/price_distribuition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added visualizations/price_distribuition_2_original.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.