A value estimate is only useful if you can say how wrong it is
An automated valuation model (AVM) returns a number: the estimated value of a property. Building it is the easy part, because with a few thousand past sales any machine learning library produces a plausible estimate. The hard part is knowing how far you can trust that number, for which properties and in which direction it errs. An AVM that is off by 10% on average can be excellent for ranking listings and unacceptable for granting a mortgage, and only measurement tells you which case you are in.
Here we build a minimal AVM on synthetic data (generated by a known formula, declared in the listing: they are not real sales from any market) and we measure it the way a valuation model is measured: with a split by time, with a comparison against a simple baseline, and with a ratio study like the one described by the IAAO standard. Using synthetic data has an honest advantage: we know the noise we put in, so we know the limit below which no model can go.
The data: a known formula, and time that moves on
The generator creates 6,000 sales in three zones. The price per square metre starts from a base value per zone, grows by 0.4% per month, drops by 0.3% for every year of the building's age and rises slightly with the floor; then it is multiplied by the square metres and by lognormal noise with a deviation of 0.12, which stands for everything a listing sheet does not capture (the view, the interior condition, the seller's hurry). That 0.12 is the error floor: with multiplicative noise of that shape, the median percentage error cannot fall below about 8%, because half of the prices deviate from the formula by at least that amount.
import numpy as np
ZONE = {"centro": 3200.0, "semicentro": 2300.0, "periferia": 1600.0} # base euro/sqm (invented)
def genera(n=6000, seed=7):
"""Synthetic sales: the price has a known formula plus noise, and a sale month."""
rng = np.random.default_rng(seed)
zona = rng.choice(list(ZONE), size=n, p=[0.2, 0.4, 0.4])
mq = rng.normal(85, 25, n).clip(35, 220)
piano = rng.integers(0, 8, n)
eta = rng.integers(0, 80, n)
mese = rng.integers(0, 36, n) # 0 = three years ago, 35 = last month
base = np.array([ZONE[z] for z in zona])
mq_prezzo = base * (1 + 0.004 * mese) * (1 - 0.003 * eta) * (1 + 0.01 * np.minimum(piano, 4))
prezzo = mq_prezzo * mq * rng.lognormal(0, 0.12, n)
return zona, mq, piano, eta, mese, prezzo
if __name__ == "__main__":
zona, mq, piano, eta, mese, prezzo = genera()
print("vendite:", len(prezzo), "| mese 0..35 | prezzo mediano:", round(float(np.median(prezzo))), "euro")
for z in ZONE:
m = zona == z
print(f"{z:11s} n={m.sum():4d} euro/mq mediano={np.median(prezzo[m] / mq[m]):7.0f}")
# Output:
# vendite: 6000 | mese 0..35 | prezzo mediano: 169447 euro
# centro n=1204 euro/mq mediano= 3085
# semicentro n=2402 euro/mq mediano= 2229
# periferia n=2394 euro/mq mediano= 1540
The output checks that the generator does what it says: three zones with distinct median euros per square
metre (about 3,085, 2,229 and 1,540, different from the base values because age, floor and growth over
time weigh on each of them). The sale month (mese, from 0 to 35) is the column that decides
everything else in the article: real estate data has a time dimension, and a model that does not respect it
is evaluated badly.
Split by time, not at random
The random split between training and test is the most common flaw in AVMs presented with brilliant numbers. If you mix the sales of all months, the model has already seen sales from the same month as the one it must predict and looks better than it will be on the day it predicts tomorrow's price. The scikit-learn documentation calls this flaw data leakage: using, in building the model, information that would not be available at prediction time. In the listing below we train on months 0-27 and evaluate on months 28-35, that is, on the future.
import numpy as np
from sklearn.ensemble import HistGradientBoostingRegressor
from dati import genera, ZONE
zona, mq, piano, eta, mese, prezzo = genera()
X = np.column_stack([[list(ZONE).index(z) for z in zona], mq, piano, eta, mese])
# Split by TIME, not random: train on the past, evaluate on the future.
passato = mese < 28
futuro = ~passato
# Baseline: median euro/sqm of the zone in the past, times the property's square metres.
mediana_zona = {z: np.median(prezzo[passato & (zona == z)] / mq[passato & (zona == z)]) for z in ZONE}
stima_base = np.array([mediana_zona[z] for z in zona]) * mq
# Model: predict the logarithm of the price, so the error is proportional.
modello = HistGradientBoostingRegressor(max_iter=200, learning_rate=0.08, random_state=0)
modello.fit(X[passato], np.log(prezzo[passato]))
stima_ml = np.exp(modello.predict(X))
def riassunto(nome, stima):
ape = np.abs(stima[futuro] - prezzo[futuro]) / prezzo[futuro]
print(f"{nome:10s} errore % mediano={100 * np.median(ape):5.1f} entro il 10%={100 * np.mean(ape <= 0.10):5.1f}%")
print("addestramento:", int(passato.sum()), "vendite | prova:", int(futuro.sum()), "vendite (mesi 28..35)")
riassunto("zona", stima_base)
riassunto("boosting", stima_ml)
# Output:
# addestramento: 4669 vendite | prova: 1331 vendite (mesi 28..35)
# zona errore % mediano= 10.8 entro il 10%= 46.9%
# boosting errore % mediano= 8.6 entro il 10%= 56.9%
The baseline is deliberately simple: the median euros per square metre of the zone, multiplied by the
property's square metres. It is what an agent would do with a spreadsheet, and it serves to avoid telling
ourselves stories: a complicated model that does not beat this baseline is not worth its complexity. The
real model is a HistGradientBoostingRegressor that predicts the logarithm of
the price: with the logarithm a 10% error weighs the same on a three-room flat and on a villa, whereas on
the raw price the villa would dominate the training. The last lines of the run report two numbers for each:
the median percentage error goes from 10.8% to 8.6%, and the share of estimates within 10% of the sale
price from 46.9% to 56.9%.
Read that 8.6% against the floor we computed: the boosting model is already close to the limit set by the
noise, so adding more features would not improve it much. The zone baseline, instead, is also wrong
because it ignores time: it has a median from the past and the price, in the test months, has risen. The
model has the mese column, but trees do not extrapolate beyond the last value seen in training
(27), and indeed the median ratio between estimate and price, which we will see shortly, stays below 1.
These numbers depend on the generator's seed and on the library version: repeating the test with another
seed will change them by a few tenths, not the order between the two models.
Measuring the way a valuation is measured: the ratio study
Percentage error is a good measure of precision, but it does not tell you whether the model has a systematic flaw. The IAAO standard on AVMs (International Association of Assessing Officers, July 2018 revision) proposes looking at the ratio between estimated value and sale price and summarising it with three numbers: the median ratio (the level: does it tend to under- or over-estimate?), the COD, coefficient of dispersion (the variability, that is, the mean absolute deviation of the ratios from the median, as a percentage) and the PRD, the price-related differential, which the standard says should be close to 1.00.
import numpy as np
from sklearn.ensemble import HistGradientBoostingRegressor
from dati import genera, ZONE
zona, mq, piano, eta, mese, prezzo = genera()
X = np.column_stack([[list(ZONE).index(z) for z in zona], mq, piano, eta, mese])
passato = mese < 28
futuro = ~passato
modello = HistGradientBoostingRegressor(max_iter=200, learning_rate=0.08, random_state=0)
modello.fit(X[passato], np.log(prezzo[passato]))
stima = np.exp(modello.predict(X))
# Ratio study the IAAO way: estimate / sale price ratio on the test sample.
r = stima[futuro] / prezzo[futuro]
mediana = np.median(r)
cod = 100 * np.mean(np.abs(r - mediana) / mediana) # coefficient of dispersion
prd = np.mean(r) / (np.sum(stima[futuro]) / np.sum(prezzo[futuro])) # mean / weighted mean
print(f"rapporto mediano={mediana:.3f} COD={cod:.1f} PRD={prd:.3f}")
# Vertical equity: does the median ratio change between cheap and expensive houses?
# Mind HOW the bands are formed: by sale price or by estimated value.
p, e = prezzo[futuro], stima[futuro]
for criterio, chiave in [("prezzo di vendita", p), ("valore stimato", e)]:
t = np.quantile(chiave, [1 / 3, 2 / 3])
fasce = [("basso", chiave <= t[0]), ("medio", (chiave > t[0]) & (chiave <= t[1])), ("alto", chiave > t[1])]
print("fasce per", criterio + ":", " ".join(f"{n}={np.median(r[m]):.3f}" for n, m in fasce))
# Output:
# rapporto mediano=0.981 COD=10.2 PRD=1.014
# fasce per prezzo di vendita: basso=1.022 medio=0.979 alto=0.953
# fasce per valore stimato: basso=0.972 medio=0.980 alto=0.988
The median ratio is 0.981: the model underestimates on average by 2%, consistent with the upward trend that is not extrapolated. The COD is 10.2 and the PRD 1.014, close to 1.00. The step not to skip is the last one: the IAAO standard speaks of vertical inequity, that is, the risk that the model treats cheap and expensive houses differently. If you form the bands on the sale price, the median ratio drops from 1.022 to 0.953 and it looks as if the model underestimates expensive houses. But if you form them on the estimated value, the three bands are 0.972, 0.980 and 0.988, practically flat.
The first result is largely an artefact: if you sort the sales by actual price, at the top end up those with positive noise (the seller got more than usual), and by construction the estimate undervalues them; at the bottom the opposite happens. I checked it with a control test, not shown in the listing, that uses a random split instead of a split by time: the same slope appears with no temporal effect at all. The practical consequence is this: before saying your model is "regressive" or "progressive", ask yourself on which quantity you formed the bands, because a wrong choice invents a flaw that is not there, and a careless choice can hide a real one.
When an AVM is not enough
The model sees only what is in one row of the table. It does not see the damp on the ceiling, the view, the noise of a road, the badly done renovation. That is why an AVM works better where houses are similar and sales are plentiful (flats in a residential neighbourhood) and worse where each property is a case on its own (a farmhouse, a commercial unit, a penthouse). A healthy practice is to accompany every estimate with an interval and with a low-confidence signal when the zone has few comparable sales, and to refer to a surveyor the cases where the interval is too wide for the intended use.
A second limit is that the model learns from history, and history contains the past decisions of those who bought and sold, including discriminatory ones. When the estimate enters a decision about a person, for example a mortgage, the topic is no longer only statistical: you will find it in the article on privacy, fair housing and algorithmic bias. For how the price history is organised before it reaches the model, see the platform architecture; for keeping the model up to date while the market moves, the real-time pipeline. If the estimate enters a mortgage application, the rules of that process are in the article on mortgage and lending. An agent that uses an estimate as one tool among others is in the article on property management with agents. To aggregate the price by zone with H3 cells, and to know how many listings a zone median needs before it says anything, see the article on H3 geographic indexing. How to set a rent on the basis of demand, and with what limits, is in the article on dynamic rental pricing.
What you can do now
You can build an AVM with a split by time, compare it with a simple baseline before believing it, and compute median ratio, COD and PRD as the IAAO standard does. Above all you know that the choice of how to form the bands can create or hide a flaw, and that a median error must be read against the noise floor of the data. What this article does not show is how an AVM behaves on your market: the data here is generated, and the figures must be redone on your real sales.
In this series, the next article is BIM and IFC Files: Model Structure and Clash Detection.
Sources
- IAAO, Standard on Automated Valuation Models (AVMs), revision approved July 2018 - median ratio, COD, PRD and the concept of vertical inequity (section 7.3), accessed on 2026-11-12
- scikit-learn, HistGradientBoostingRegressor - parameters and behaviour of the estimator used in the listing, accessed on 2026-11-12
- scikit-learn, Common pitfalls and recommended practices (data leakage) - the definition of data leakage used to motivate the split by time, accessed on 2026-11-12
The three listings were run with Python 3.14 and scikit-learn on 2026-11-12. The data is synthetic: every figure in the article (3,085, 8.6%, 0.981 and the others) is the output of that run with the seed shown and does not describe any real market.

Commenti
Caricamento commenti...
Sign in to comment