All work

RoofWorth

Estimate a California home’s value from eight housing and neighborhood inputs.

Previously AI House Price Estimator

RoofWorth home page with an illustrated California house and the property profile form

From property profile to price

Follow eight California housing inputs through feature scaling, a 200-tree Random Forest, model validation, and the FastAPI service behind each estimate.

How the model makes an estimate

Scikit-Learn 1.4 • Joblib Serialization • 5-Fold Cross Validation

  1. Feature scaling

    raw census signalsnormalized 8D vectors

  2. Random Forest

    bootstrapped subsets200-tree ensemble vote

  3. Validation

    36 candidate configurationsR² 0.8062 convergence

  4. Serving

    HTTP POST requestinstantaneous valuation

Scaling eight housing inputs

Raw census block records are transformed into continuous z-scores across median income, room ratios, household densities, and high-precision GPS coordinates.

raw census signalsnormalized 8D vectors
  • standard scaler pipeline
  • zero-variance outlier filtering
MedInc: 3.870Rooms: 5.43Lat: 35.63°NLng: -119.57°W
RoofWorth form with eight property and neighborhood inputs next to an empty estimate panel
Property profile

A forest of 200 trees

Bootstrapped decision trees vote on non-linear price splits, dampening outlier leverage in multi-modal California real estate sub-markets.

bootstrapped subsets200-tree ensemble vote
  • bootstrap aggregation
  • decorrelated feature subspace
MedInc: 5.210Rooms: 6.12Lat: 37.88°NLng: -122.23°W
RoofWorth property profile populated with an example California home
Example home

Tuning and validating the model

Exhaustive grid search isolates optimal tree depth and split criteria across 5 held-out folds, preventing localized data leakage.

36 candidate configurationsR² 0.8062 convergence
  • 5-fold cross validation
  • leak-free fold isolation
MedInc: 8.325Rooms: 6.98Lat: 37.85°NLng: -122.25°W
Preparing your estimate overlay showing RoofWorth connecting to the valuation service
Service warm-up

Serving the estimate

Serialized model weights are hosted on an asynchronous FastAPI worker with Pydantic validation and interactive Swagger documentation.

HTTP POST requestinstantaneous valuation
  • sub-10ms async inference
  • Pydantic schema validation
MedInc: 4.650Rooms: 5.80Lat: 34.22°NLng: -118.45°W
Sage RoofWorth estimate card showing $293,378, the model score, and a recent estimates list
Estimate result

Try the valuation simulator

FASTAPI /api/predict • 6.8ms
California Micro-Market Enclaves:
$83.2k/yr (8.32)
Low Income (1.5)State Median (5.2)High Income (15.0)
HouseAge41 yrs
AveRooms6.98
Latitude37.88°N
Longitude-122.23°W
Illustrative district valueR² 0.8062
$692,800
Model mean absolute error$32,610
RoofWorth • Applied ML Architecture & Benchmarks

Model evaluation

Random Forest + FastAPI + React, tuned with GridSearchCV and deployed on Render and Vercel.

Accuracy Metric
R² 0.8062

Cross-validated coefficient of determination across held-out splits

Error Margin
MAE 0.3261

Mean absolute error on test split (~$32.6k deviation envelope)

Inference Speed
< 10ms

Asynchronous FastAPI REST endpoint execution latency

Random Forest Feature Importance Analysis

Gini Impurity Reduction • 8-Dimensional Input
MedIncMedian Household Income
52.3%

Primary economic predictor of district property values

Lat & LngGeospatial Coordinates
18.7%

Proximity to coastal economic hubs (SF Bay Area, Silicon Valley, LA basin)

AveOccupAverage Household Occupancy
14.1%

Density ratio measuring household crowding versus luxury single-family ratios

AveRooms / BedrmsRoom & Bedroom Ratios
8.1%

Physical spatial layout and structural capacity index

HouseAgeMedian Housing Age
6.8%

Construction era reflecting historical preservation and municipal infrastructure

Model Benchmark & Evaluation Matrix

Evaluated on Held-Out Test Split (20%)
Baseline Linear

Linear Regression

R² Score:0.6062
MAE:0.5280
Latency:2ms
L2 Regularized

Ridge Regression (L2)

R² Score:0.6063
MAE:0.5274
Latency:2ms
Unpruned Tree

Decision Tree Regressor

R² Score:0.6210
MAE:0.4412
Latency:4ms
200 Bagged Trees + GridSearchCVWinner

Tuned Random Forest (Ours)

R² Score:0.8062
MAE:0.3261
Latency:8ms

5-Fold Cross-Validation & Hyperparameter Grid

Scikit-Learn GridSearchCV • K-Fold cv=5
Held-Out Split Generalization (K-Fold cv=5)
Fold 01
Train R²: 0.8312Val R²: 0.8045MAE 0.3280
Fold 02
Train R²: 0.8295Val R²: 0.8089MAE 0.3241
Fold 03
Train R²: 0.8320Val R²: 0.8031MAE 0.3298
Fold 04
Train R²: 0.8308Val R²: 0.8074MAE 0.3255
Fold 05
Train R²: 0.8317Val R²: 0.8068MAE 0.3272
Mean Cross-Validation Score:R² = 0.8062 (±0.0021)
GridSearchCV Parameter Optimization Space
n_estimatorsSelected: 200
Evaluated: [50, 100, 200]

Minimizes tree correlation & ensemble variance

max_depthSelected: None (Full)
Evaluated: [15, 25, 35, None]

Captures non-linear geospatial interactions

min_samples_splitSelected: 5
Evaluated: [2, 5, 10]

Eliminates leaf-level memorization of localized noise

max_featuresSelected: 1.0 (All 8)
Evaluated: ['sqrt', 'log2', 1.0]

Preserves coordinate coupling (latitude + longitude)

Total Candidate Fits:180 Fits (36 Candidates × 5 Folds)
Code & Boundary Inspector

Applied Machine Learning Mechanics

01 of 04

Feature Space

Preparing the housing inputs

Inputs incorporate 8 numerical dimensions from the California housing dataset including median income, housing age, average rooms, population density, and GPS coordinates.

Features8 Numerical Dimensions
DatasetCalifornia Housing
NormalizationStandardScaler pipeline
PandasNumPyFeature Scaling
estimator/ml/preprocessing.py
import pandas as pd
import numpy as np

def prepare_features(df):
    features = ['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup', 'Latitude', 'Longitude']
    return df[features]
Scikit-Learn / FastAPIOptimized Weights
02 of 04

Random Forest Ensemble

Averaging the tree predictions

The model builds 200 regression trees across bootstrapped samples, averaging splits to minimize variance and prevent overfitting on outlier districts.

Estimators200 Decision Trees
TaskContinuous Regression
CriterionSquared Error
Scikit-LearnRandom ForestEnsemble Regressor
estimator/ml/random_forest_model.py
from sklearn.ensemble import RandomForestRegressor

model = RandomForestRegressor(
    n_estimators=200,
    max_depth=None,
    min_samples_split=5,
    random_state=42,
    n_jobs=-1
)
Scikit-Learn / FastAPIOptimized Weights
03 of 04

Hyperparameter Optimization

Tuning with five folds

Exhaustive hyperparameter sweeps via GridSearchCV with 5-fold cross-validation optimized tree depth, feature splits, and leaf samples to achieve an R² of 0.8062 and MAE of 0.3261.

Validation5-Fold Cross-Validation
R² Score0.8062 accuracy
MAE0.3261 error margin
GridSearchCVCross-ValidationHyperparameter Tuning
estimator/ml/grid_search_tuning.py
from sklearn.model_selection import GridSearchCV

param_grid = {'n_estimators': [100, 200], 'max_depth': [20, 30, None]}
grid_search = GridSearchCV(estimator=RandomForestRegressor(), param_grid=param_grid, cv=5, scoring='r2')
grid_search.fit(X_train, y_train)
Scikit-Learn / FastAPIOptimized Weights
04 of 04

API Serving Boundary

Serving predictions with FastAPI

Tuned model weights are serialized using Joblib and loaded into a lightweight FastAPI service, enabling instantaneous predictions through documented Swagger REST endpoints.

BackendFastAPI Async API
ArtifactsSerialized Joblib model
DocumentationInteractive Swagger /docs
FastAPIJoblibREST EndpointsSwagger Docs
estimator/api/main.py
from fastapi import FastAPI
import joblib

app = FastAPI()
model = joblib.load("random_forest_model.joblib")

@app.post("/predict")
def predict_price(data: HouseFeatures):
    prediction = model.predict([data.to_array()])
    return {"predicted_price": float(prediction[0])}
Scikit-Learn / FastAPIOptimized Weights