Spatial Machine Learning

Why the usual rules break, and what to do instead.

Spatial data violates the one assumption every default in scikit-learn is built on: that rows are independent. Nearby samples are near-duplicates, so a random train-test split scores a model on data it has effectively seen, and the number that comes out is not wrong so much as answering a question nobody asked. These guides cover leakage and spatial cross-validation, building features that generalise, turning predictions back into a raster, the area of applicability, and reading a prediction map for the artefacts that say the model is extrapolating.

14 Steps in this path

The full path, in order

14 guides: the concepts underneath the work, then each task, then the errors that task produces. Work down, or jump to the step you need.

  1. Spatial Leakage Explained: Why Random Cross-Validation Lies spatial leakage explained 🧭 Concept
  2. Spatial Features Explained: Turning Geometry into Columns spatial features explained 🧭 Concept
  3. How to Sample Training Points from Rasters and Polygons sample training points python ⚙️ How-To
  4. How to Build Spatial Features for a Machine Learning Model build spatial features python ⚙️ How-To
  5. How to Do Spatial Cross-Validation in Python spatial cross validation python ⚙️ How-To
  6. My Model Scores 0.95 in Testing and Fails in the Field model scores high fails in field 🔧 Fix
  7. How to Predict a Continuous Surface with Random Forest random forest spatial prediction python ⚙️ How-To
  8. How to Turn Model Predictions Back into a Raster predictions to raster python ⚙️ How-To
  9. My Prediction Raster Is Striped, Blocky or Full of NoData prediction raster artefacts 🔧 Fix
  10. How to Evaluate a Spatial Model Honestly evaluate spatial model python ⚙️ How-To
  11. Extrapolation in Space Explained: The Area of Applicability area of applicability explained 🧭 Concept
  12. Feature Importance Says Coordinates Are the Best Predictor coordinates dominate feature importance 🔧 Fix
  13. How to Handle Class Imbalance in a Spatial Classifier class imbalance spatial classifier ⚙️ How-To

Topics this path covers

A path is a route; a topic is everything the site has on a subject. Open a topic to see the guides this path skips.

Other ways in