tschool01/zurich-apartment-price
0
Apartment Price Prediction (Regression)
Task: Predict monthly rental prices for apartments in the canton of Zurich
Summary of Iterative Process
Notes
Metric: R² and RMSE (CHF) – 5-Fold Cross-Validation
Created Features:
employment_rate=emp / pop– fraction of the municipal population that is employed (new feature, not in prior exercises)
Final Selected Features:
rooms– number of roomsarea– living area in m²pop– municipal populationpop_dens– population density (per km²)frg_pct– percentage of foreign residentsemp– number of employees in municipalitytax_income– average taxable incomeemployment_rate– emp / pop (engineered)
Reason for Selection: Selected based on availability in the BFS municipality dataset (enabling live lookup in the app), feature importance from the Random Forest, and cross-validation performance improvement when adding employment_rate. The new feature reduces the gap between train and test R², indicating better generalisation.
Preprocessing Steps
- Load raw apartment listing CSV merged with BFS municipality socioeconomic data
- Remove rows with missing values (
dropna()) - Remove duplicate rows (
drop_duplicates()) - Engineer new feature:
employment_rate = emp / pop - Select final 8 features as input;
price(CHF/month) as target - No feature scaling applied – tree-based models are scale-invariant
Final Model
RandomForestRegressor (tuned, Iteration 2)
Selected based on lowest cross-validation RMSE in Iteration 2. Trained on the full dataset and saved as apartment_price_model.pkl.
