How to predict property value using lat/lon?

I have lat/lon and property values for households in a particular region.

Format:
Lat     Lon      value
32.2  -98.22    120000
....


Now I have new data of the same region, but just have lat/log values. I want to estimate the household values using some nearest neighbor algorithm. Which is the best algorithm for this purpose? I am currently working with KDTrees from Scipy. Thanks

• Kriging seems like the natural choice.
– Sycorax
Jul 14, 2015 at 16:40
• What's the purpose of this prediction? Mar 2, 2016 at 22:06
• Estimating household value of houses for which I dont have information
– icm
Mar 4, 2016 at 14:47

Kriging will work, since at it's core it is similar to IDW in that it uses surrounding measured values to predict values at an unknown location, with a few perks of being a geostatistical interpolator (including producing semivariograms to help the user understand spatial auto-correlation). I'd also recommend looking into IDW and other interpolation methods to see what suits your needs best. The better spatial coverage your sample points have the better your result will be. If you have access to a GIS package like ArcGIS, through your university this process is straightforward. If not, QGIS is a very capable open source solution. As pointed out below, achieving greater accuracy in your Lat/Long fields would be highly beneficial despite your interpolation method of choice.

• Can you add a couple sentences about why you think kriging will work? There are assumptions behind this method. Jul 14, 2015 at 18:21
• Hedonic pricing models developing using kriging have worked, but they show that over regions the size of the imprecision in the coordinates of the question (a latitude given only to $0.1$ degrees is uncertain by over $5$ kilometers north and south!) the stationarity assumption will be difficult to justify. At a minimum, covariates would be needed. BTW, it's hard to tell what you mean by "at its core," because kriging is substantially different from IDW in almost any aspect that matters.
– whuber
Jul 14, 2015 at 18:52
• What is IDW? ............................... Mar 2, 2016 at 22:20
• IDW stands for Inverse distance weighting Feb 28, 2017 at 2:06

knn is probably a good, simple approach, but tree-based models may work too, and would let you easily incorporate other data (e.g. number of rooms, etc.).

Here's a simple example (in R, but all the code would be pretty easy to port to scikit-learn). First, we make a spatially correlated dataset:

library(gstat)
library(ggplot2)
set.seed(42)
N <- 10000
dat <- data.frame(
lat = rnorm(N, mean=32.2, sd=10),
lon = rnorm(N, mean=-98.22, sd=10)
)
g.dummy <- gstat(
formula=z~1,
locations=~lat+lon,
dummy=T,
beta=.5,
model=vgm(psill=0.025, range=5, model='Exp'),
nmax=20)
dat$value <- 120000 ^ predict(g.dummy, newdata=dat, nsim=1)$sim1
dat$log_value <- log10(dat$value)
ggplot(dat, aes(x=lat, y=lon, color=log_value)) +
geom_point() + theme_bw() + scale_colour_gradient(low="blue", high="orange")


Then we can use both a knn and a random forest (with lat/lon as inputs) to predict values:

library(caret)
X <- dat[,c('lat', 'lon')]
Y <- dat[,'log_value']
ctrl <- trainControl(
method='cv', number=10,
verboseIter=TRUE,
index=createFolds(Y, 10))
model_knn <- train(X, Y, method='knn', tuneLength=5, trControl=ctrl)
model_rf <- train(
X, Y, method='rf',
tuneGrid=data.frame(mtry=2), trControl=ctrl)


The caret package in R makes it easy to compare regression models (scikit-learn has similar tools):

dotplot(resamples(list(
knn = model_knn,
rf = model_rf
)), metric='RMSE')


For this specific dataset, the knn model (with k = 5) is a bit more accurate, but the random forest is close. If you have other variables you could include in your model, the random forest will probably have an easier time incorporating non-spatial variables.

There are of course many other kinds of models aimed specifically at solving this sort of problem. No matter the model you choose, you should cross-validated it and compare it's out of sample predictions to other models.