- Introduced by
- Stefanos Georganos et al.
- Year
- 2021
- Type
- Spatially local ensemble learning method
- Family
- Spatial machine learning
What does it do?
Geographically Weighted Random Forest (GWRF) is a spatially local ensemble learning method that fits an independent Random Forest model at each observation location.
For each target location, a spatial kernel function gives nearby training samples more weight than distant ones, and the weighted sample is used to fit that location's forest. It extends Breiman's Random Forest to handle spatial non-stationarity, the phenomenon in which predictor–response relationships vary across geographic space. The method was introduced by Stefanos Georganos and colleagues in 2021.
The intuition behind the method
Imagine asking a local expert in each neighborhood about housing prices rather than relying on a single national model. A global Random Forest learns one set of rules for the entire study area, but local patterns — say, how proximity to the sea affects land value — differ by region. GWRF trains a separate forest at every location, giving more influence to nearby data points, so the model adapts its predictions to the local geographic context rather than imposing one-size-fits-all relationships.
History
The method was introduced by Georganos and colleagues in a 2021 article in Geocarto International. It builds on Breiman's Random Forest and on the geographically weighted framework that underlies Geographically Weighted Regression.
When to use it
Choose GWRF when there is evidence or a strong expectation that the relationship between predictors and a continuous, georeferenced response changes across the study area, and when the question concerns how that variation is spatially patterned. The data should cover the area densely enough that each local forest receives sufficient weighted training observations; very small datasets are unreliable, as the pitfalls section notes. Do not use it for purely temporal or aspatial data, or where relationships are expected to be stable across space, since a global Random Forest is simpler in that case. If the relationships are expected to be linear and local coefficients are the target of interest, Geographically Weighted Regression is the closer alternative.
Limitations and considerations
- Computationally expensive: a separate forest is fitted at each location and the bandwidth search refits models for each candidate, so cost rises quickly with sample size
- Bandwidth selection by leave-one-out cross-validation can be unstable when samples are sparse or clustered, because a held-out point may have few usable neighbours
- Local forests near the edge of the study area draw on fewer neighbours, which can increase prediction variance there
- Local importance values lack a formal inference framework, so uncertainty in the mapped VI_kj surfaces is hard to quantify
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Captures spatial non-stationarity in predictor–response relationships without assuming a linear form
- Produces spatially varying variable importance surfaces (VI_kj), allowing regions to be compared on which drivers dominate
- Each local forest can represent non-linear effects and interactions among predictors, which a local linear model cannot
- The kernel can be Gaussian or adaptive bisquare, giving some control over how the local neighbourhood is defined
Applications
- Urban deprivation and poverty mapping from remote sensing and census data
- House price modelling to identify spatially varying hedonic effects
- Species distribution and ecological habitat suitability modelling
- Air quality and environmental exposure surface estimation across heterogeneous landscapes
- Crime hotspot analysis capturing neighbourhood-specific socio-economic driver patterns
How it works
How it works
For each target location j with coordinates (u_j, v_j), a spatial kernel assigns each training sample i a weight w_i that decreases with the distance d_ij between i and j, following the Gaussian form given in the mechanics. The bandwidth h sets how quickly the weights decay: a small h gives very local models, and a large h makes the local forest resemble a global one. The software offers either a Gaussian or an adaptive bisquare kernel. The weighted observations form the local training set for the forest at j.
Formula
w_i(u_j, v_j) = \exp\!\left(-\frac{d_{ij}^2}{h^2}\right)An independent forest of B trees is grown on the weighted local dataset at each location j. Each tree T_b is trained on bootstrap resamples of the local data, with random feature subsampling at each split, as in standard Random Forest practice. The local prediction is the average of the B tree outputs, as the mechanics formula states. Because a separate forest is fitted for each observation, the resulting prediction surface can vary across space, loosely analogous to the spatially varying coefficients of Geographically Weighted Regression but without that method's linear form.
Formula
\hat{y}_j = \frac{1}{B}\sum_{b=1}^{B} T_b\!\left(\mathbf{x}_j;\, \mathcal{D}_j^w\right)The bandwidth h* is chosen by leave-one-out cross-validation: each observation j is held out in turn, predicted from a forest fitted to the remaining local data, and the squared prediction errors are summed, as the mechanics formula states. The value of h that minimises this sum is retained, found by searching over candidate values. Because every candidate h requires refitting the model for each observation, this step is computationally intensive.
Formula
h^* = \arg\min_{h}\; \sum_{j=1}^{n} \left(y_j - \hat{y}_{-j}(h)\right)^2After fitting, the local variable importance VI_kj for each predictor k is computed at every location j as the average, over the B trees, of the difference between the error with feature k permuted and the error without permutation, following the mechanics formula. Mapping these values shows which predictors matter most in which parts of the study area, an output that a single global Random Forest does not provide.
Formula
\text{VI}_{kj} = \frac{1}{B}\sum_{b=1}^{B}\left[\overline{\text{err}}_{b,j}^{\text{perm}(k)} - \overline{\text{err}}_{b,j}\right]Common pitfalls
- When sample density is highly irregular, a single fixed bandwidth can over-smooth sparse areas and under-smooth dense ones; comparing a fixed and an adaptive kernel on the data is a practical check
- Interpreting local variable importance surfaces as causal spatial effects without accounting for omitted spatially structured confounders is misleading
- Very small datasets may yield unstable local forests, because few training observations remain after kernel weighting, particularly near the study-area boundary; check the effective number of weighted neighbours at each location
- Neglecting to check for global spatial autocorrelation in residuals after fitting may mask model misspecification that a spatial lag or error specification would address
Frequently asked questions
How does GWRF differ from standard Geographically Weighted Regression?
GWR estimates a linear model locally at each point, so it cannot capture non-linear predictor interactions or handle high-dimensional feature spaces without strong overfitting risk. GWRF replaces the linear estimator with a Random Forest, allowing arbitrary non-linear relationships and automatic interaction detection while retaining the geographically weighted localisation principle.
What sample size is needed for GWRF to produce reliable results?
There is no established minimum sample size. What matters more is whether each local forest receives enough weighted training observations, which depends on the chosen bandwidth and on the spatial density of samples. Very small datasets risk degenerate local forests, particularly near the study-area boundary where spatial neighbours are sparse.
Can GWRF handle classification tasks or only regression?
The original formulation targets continuous response variables (regression), and the geographically weighted extension and the R package SpatialML are described here for regression. The underlying Random Forest engine supports classification; a geographically weighted classification variant would replace the averaging step with a voting rule and would need its own validation.
Related methods
Sources
Georganos, S., et al. (2021). Geographical random forests: a spatial extension of the random forest algorithm. Geocarto International, 36(2), 121–136.
Open publication reference