This model estimates the sale price of a house in King County (Washington, USA, including Seattle) from 13 facts about the building and its location (floor area, rooms, floors, grade, condition, age, renovation, latitude/longitude and ZIP code). It is meant for architects, developers, buyers and real-estate professionals who want a quick first estimate, for example to compare design options for a plot in a feasibility study, before a professional valuation. It is a small multilayer perceptron (82 inputs → 64 → 32 → 1, ReLU, 7,425 parameters), trained from scratch with PyTorch on 2014–2015 sales, that predicts log10(price). On the test set it is typically 12.6% off the true price (R² = 0.877 on log10(price)). It comes close to our Day 2 gradient boosting model but does not beat it (12.2%, R² = 0.886). It was built as a course assignment for AI Methods I (IAAC MaAI 2026/27).
Predicted against actual price for the 4,147 test houses, for the Day 2 gradient boosting model (left) and this network (right). Both follow the diagonal and about 80% of the houses fall inside the ±20% band; the largest misses are expensive houses that are under-estimated and a few cheap houses that are over-estimated.
What the model does: two hand-made design options on the same plot in ZIP 98117, keeping a 1952 house of 1,500 sqft (about 504,000 USD) or replacing it with a new 2,800 sqft house (about 825,000 USD). The shaded bands show the test-set uncertainty: the ranking is clear, but each estimate is typically ±12.6% off.
| Model (test set, 4,147 houses) | R² on log10(price) | Typical error | Mean error (USD) |
|---|---|---|---|
| Baseline: dummy (always the average price) | 0.000 | 47.0% | 196,281 |
| Baseline: Day 2 gradient boosting | 0.886 | 12.2% | 60,201 |
| This model | 0.877 | 12.6% | 62,797 |
Typical error = 10^MAE(log10) − 1: how far, in percent, a prediction usually is from the true price.
| Task | Tabular regression: log10(price) of one house sale (price in USD) |
| Architecture | MLP: 82 inputs → Linear 64 → ReLU → Linear 32 → ReLU → Linear 1 (no dropout) |
| Parameters | 7,425 (all trainable) |
| Base model | None, trained from scratch |
| Input | 13 columns (see below): 12 numeric columns standardised with a StandardScaler + zipcode one-hot encoded (70 ZIP codes) = 82 inputs. The fitted preprocessor is scaler.joblib |
| Output | One number: the predicted log10(price). The price in USD is 10 ** output |
| Files | model.pt (the state_dict, 32 KB), scaler.joblib (the fitted scikit-learn ColumnTransformer, 3 KB), figures |
| Library versions | Saved with Python 3.14.7, torch 2.14.1, scikit-learn 1.9.1, joblib 1.6.0, pandas 3.0.6, numpy 2.5.3 |
The columns must be given in this order: bedrooms, bathrooms, sqft_living, sqft_lot, floors, condition, grade, sqft_basement, yr_built, yr_renovated, lat, long, zipcode. The range is what the model saw in the data (min – max).
| Column | Type | Unit / meaning | Range in the data | Preprocessing |
|---|---|---|---|---|
bedrooms |
integer | number of bedrooms | 2 – 6 | standardised |
bathrooms |
number | bathrooms (0.25 steps: a toilet only counts 0.5) | 0.5 – 5.25 | standardised |
sqft_living |
integer | interior living area, sqft | 720 – 4,970 | standardised |
sqft_lot |
integer | lot area, sqft | 520 – 1,651,359 | standardised |
floors |
number | number of floors (0.5 = split level) | 1 – 3.5 | standardised |
condition |
integer | condition of the house, 1 (poor) – 5 (very good) | 1 – 5 | standardised |
grade |
integer | King County building grade, quality of construction and design, 1 – 13 | 4 – 13 | standardised |
sqft_basement |
integer | basement area, sqft (0 = no basement) | 0 – 2,350 | standardised |
yr_built |
integer | year built | 1900 – 2015 | standardised |
yr_renovated |
integer | year of the last renovation, 0 if never renovated | 0 or up to 2015 | standardised |
lat |
number | latitude, degrees | 47.156 – 47.778 | standardised |
long |
number | longitude, degrees | −122.519 – −121.316 | standardised |
zipcode |
integer (category) | ZIP code | 70 ZIP codes of King County | one-hot; an unknown ZIP code gets all zeros |
| Dataset | House Sales in King County, USA, as cleaned in our Day 1 / Day 2 repository |
| Source | Kaggle: harlfoxem/housesalesprediction |
| Licence | CC0 1.0 (public domain) |
| Size | 20,703 sales (one row = one sale): train 13,244 / validation 3,312 / test 4,147 |
| Splits | The test set is exactly our Day 2 test set (GroupShuffleSplit, 20%, random_state=42, grouped by house id so both sales of a house sold twice stay on the same side). Validation = 20% of the Day 2 training set, split the same way |
| Coverage | Houses sold in King County (Washington, USA, including Seattle) between May 2014 and May 2015 |
| Cleaning | Done on Day 1: dates converted, waterfront and view columns removed, extreme prices, living areas and bedroom counts filtered out. The preprocessor is fitted on the training set only |
ReduceLROnPlateau), weight decay 1e-4, Huber loss (δ = 0.05) on log10(price), batches of 64, up to 300 epochs, seed 42. The output bias starts at the average log10(price) of the training set.Typical error after each epoch. Left: the first settings start at 154% error and zig-zag around 14–17%. Right: the final settings start at a sensible level and become smooth after each halving of the learning rate. The training error ends only about 0.5 point below the validation error, so there is little overfitting.
Test set: 4,147 houses, used once, next to the two baselines.
| Metric (test set) | Dummy | Day 2 gradient boosting | This model |
|---|---|---|---|
| R² on log10(price) | 0.000 | 0.886 | 0.877 |
| Typical error | 47.0% | 12.2% | 12.6% |
| Mean absolute error (USD) | 196,281 | 60,201 | 62,797 |
| Houses within ±10% | – | 55.8% | 54.4% |
| Houses within ±20% | – | 80.6% | 79.8% |
On validation the gap was the same (12.3% against 11.9% for the Day 2 model), so the experiments did not overfit the validation set. For a single house the two models are about equally good: this network is closer to the true price than the Day 2 model for 48% of the test houses.
Typical error per price band (each band = 20% of the test houses):
| Price band (USD) | Day 2 gradient boosting | This model |
|---|---|---|
| 154k – 300k | 13.5% | 13.7% |
| 300k – 398k | 11.1% | 11.4% |
| 398k – 515k | 11.3% | 11.3% |
| 515k – 685k | 10.4% | 10.9% |
| 685k – 1,950k | 14.7% | 15.9% |
In the middle of the market the network is about as good as gradient boosting. It loses at both ends, most of all for the most expensive 20% of houses (the figure comes from the notebook run; the table above gives the numbers of the published weights).
Where it fails: the largest errors are houses that sold far below what their description suggests, which the model cannot recognise: for example a new 4,460 sqft house sold for 490,000 USD and predicted at 1.4 million, and old houses on very large lots. It is least reliable for houses under about 300,000 USD and over about 685,000 USD, where the training data is thinnest.
waterfront and view columns, so the most unusual and most expensive houses are under-represented.The data contains no people and no personal information beyond public sale records of houses. Because a price estimate can affect people (a seller, a buyer, a borrower), the model must not be used for any decision about a specific property or person (see Out-of-scope uses).
A state_dict only contains the numbers, so the network must first be rebuilt with exactly this nn.Sequential. The preprocessor (scaler.joblib) turns the 13 columns, in this order, into the 82 inputs.
import joblib
import pandas as pd
import torch
from torch import nn
from huggingface_hub import hf_hub_download
REPO = "iaac-maai/day4-group2-house-price-mlp"
COLUMNS = ["bedrooms", "bathrooms", "sqft_living", "sqft_lot", "floors", "condition", "grade",
"sqft_basement", "yr_built", "yr_renovated", "lat", "long", "zipcode"] # this order
model = nn.Sequential( # exactly the trained architecture: 82 -> 64 -> 32 -> 1
nn.Linear(82, 64), nn.ReLU(),
nn.Linear(64, 32), nn.ReLU(),
nn.Linear(32, 1),
)
model.load_state_dict(torch.load(hf_hub_download(REPO, "model.pt"), map_location="cpu"))
model.eval()
preprocess = joblib.load(hf_hub_download(REPO, "scaler.joblib")) # StandardScaler + one-hot ZIP code
house = pd.DataFrame([{
"bedrooms": 3, "bathrooms": 1.0, "sqft_living": 1500, "sqft_lot": 4432, "floors": 1.0,
"condition": 3, "grade": 7, "sqft_basement": 0, "yr_built": 1952, "yr_renovated": 0,
"lat": 47.686, "long": -122.379, "zipcode": 98117,
}])[COLUMNS]
x = torch.tensor(preprocess.transform(house), dtype=torch.float32)
with torch.no_grad():
log_price = model(x).item()
print(f"Screening estimate: {10 ** log_price:,.0f} USD (2014-2015 prices, typically ±12.6%)")
This prints Screening estimate: 504,490 USD (2014-2015 prices, typically ±12.6%): option A of the application above (the notebook gives 504,491 USD with unrounded coordinates and lot size).
⚠️ Security note: .pt and .joblib files are Python pickles and can execute code when they are loaded: only load models from sources you trust. torch.load uses weights_only=True by default for the weights; the scaler needs a full unpickle, so load it only from this repository. Use the library versions listed above (a different scikit-learn version may fail to load scaler.joblib or warn).
The full pipeline is in the GitHub repository: https://github.com/iaac-maai/2-day4-assignment. Run notebook/neural_network.ipynb (from the notebook/ folder) with the packages pinned in requirements.txt; the cleaned data is downloaded automatically. Sections 7 and 8 of the notebook save, reload and apply this model.
.gitignore, explain errors and adapt the class notebook to our data. We wrote the notebook code ourselves and checked every answer.Karthikeyan Saravanan, Emmanuel Marquez, Bars Babila, Samiha Abeda Nur. Course assignment for AI Methods I: Machine Learning for the Built Environment, IAAC MaAI 2026/27.
Model released under the MIT License. The data is CC0 1.0 (public domain): House Sales in King County, USA.