run il-prezzo-e-il-luogo.bas
MDN-120:19
DEMO by Michele di Nuzzo

Price is place

MDN · LAB PRICE IS PLACE KNN on a map · 1997
k vicini
k neighbours: how many enter the average, from 1 to 200
mostra i gruppi di isolati
show or hide the block groups on the map
cliccate un punto
click a point on the map: its neighbours, the true value and the prediction

▶ Run ⬇ Download (.html)

The lab predicts the value of Californian houses knowing only where they are, with the average of the k neighbours. The map is coloured by the predictions on 5,000 block groups from the 1990 census; on the right is the error on the groups left out, as k changes. The lab’s interface is in Italian.

Things to try

  • A single neighbour: with k = 1 the map is a mosaic and the error is high.
  • The coast: with 5 or 10 neighbours the map becomes readable and high prices lie along the coast.
  • Too many neighbours: with 200 the coast blurs into the interior and the error rises again.

The article: Price is place.

The demo is a single HTML file: download it and use it offline, even without an internet connection. Licence: CC BY-NC 4.0 — you may share it, crediting the author and this page, but not for commercial purposes.