Abstract
Evaluating the predictive performance of species distribution models (SDMs) under realistic deployment scenarios requires careful handling of spatial and temporal dependencies in the data. Cross-validation (CV) is the standard approach for model evaluation, but its design strongly influences the validity of performance estimates. When SDMs are intended for spatial or temporal transfer, random CV can lead to overoptimistic results due to spatial autocorrelation (SAC) among neighboring observations. We benchmark four machine learning algorithms (GBM, XGBoost, LightGBM, Random Forest) on two real-world presence-absence datasets, a temperate plant and an anadromous fish, using multiple CV designs: random, spatial, spatio-temporal, environmental, and forward-chaining. Two training data usage strategies (LAST FOLD and RETRAIN) are evaluated, with hyperparameter tuning performed within each CV scheme. Model performance is assessed on independent out-of-time test sets using AUC, MAE, and correlation metrics. Random CV overestimates AUC by up to 0.16 and produces MAE values up to 80 percent higher than spatially blocked alternatives. Blocking at the empirical SAC range substantially reduces this bias. Training strategy affects evaluation outcomes: LAST FOLD yields smaller validation-test discrepancies under strong SAC, while RETRAIN achieves higher test AUC when SAC is weaker. Boosted ensemble models consistently perform best under spatially structured CV designs. We recommend a robust SDM workflow based on SAC-aware blocking, blocked hyperparameter tuning, and external temporal validation to improve reliability under spatial and temporal shifts.
Introduction
In ecology, Species Distribution Modeling (SDM) is a cornerstone for predicting where a species might occur based on environmental variables. These models are essential for conservation planning and understanding climate change impacts. However, a significant challenge in SDM is Spatial Autocorrelation (SAC)—the tendency for observations close in space to be more similar than those further apart.
Standard "random" cross-validation (CV) often ignores SAC, leading to a "honesty gap." Because training and testing points are geographically proximal, the model can "memorize" local patterns rather than learning generalizable ecological relationships. This results in models that perform well on validation data but fail when applied to new regions or future time periods.
Methodology
To address this, we benchmarked four machine learning algorithms—GBM, XGBoost, LightGBM, and Random Forest—across five distinct cross-validation designs:
- Random CV: The baseline approach, which often leads to overoptimistic results.
- Spatial Blocking (SP): Dividing the study area into blocks to ensure geographic separation between training and testing sets.
- Spatio-temporal Blocking (SPT): Separating data by both geography and time.
- Environmental Blocking (ENV): Clustering data based on environmental similarity rather than geography.
- Forward-Chaining (TSS): A time-series approach where models are trained on past data to predict future occurrences.
The workflow, as illustrated in Figure 1, emphasizes the separation of "in-time" data for training and validation from "out-of-time" data for independent testing. We also evaluated two final deployment strategies:
- RETRAIN: Tuning hyperparameters via CV, then retraining the model on the entire dataset.
- LAST FOLD: Using only the model from the final CV fold to maintain strict spatial independence, albeit with less training data.
Experimental Setup
The study utilized two real-world presence-absence datasets with contrasting spatial characteristics:
- Gentianella campestris: A temperate plant (Sweden/Norway) with a high SAC range of approximately 422 km.
- Thaleichthys pacificus (Eulachon): An anadromous fish (US West Coast) with a smaller SAC range of approximately 85 km.
Hyperparameter tuning was performed within each specific CV scheme to ensure that the tuning process itself did not benefit from spatial leakage.
Results and Discussion
The Deception of Random CV
Our results confirm that random CV is highly deceptive. It overestimated the Area Under the Curve (AUC) by as much as 0.16 and underestimated Mean Absolute Error (MAE) by roughly 75% compared to independent test sets. By blocking data at the empirical SAC range, we were able to significantly mitigate this bias.
Model Performance and Strategy
Boosted ensemble models (XGBoost and LightGBM) consistently outperformed Random Forest across spatially blocked designs. For the fish dataset, the best-performing XGBoost model achieved an AUC of 0.832 under spatio-temporal blocking.
The choice between RETRAIN and LAST FOLD depends on the strength of SAC. LAST FOLD proved more conservative and reliable when spatial clustering was intense, whereas RETRAIN was more effective when data was sparse and SAC was weaker.
Conclusion
To build reliable SDMs, researchers must move beyond random cross-validation. We recommend a workflow centered on:
- SAC-aware blocking: Using empirical spatial autocorrelation ranges to define CV blocks.
- Internalized Tuning: Performing hyperparameter optimization within the blocked CV structure.
- External Validation: Utilizing independent temporal or spatial hold-out sets to verify model robustness.
These steps ensure that SDMs are evaluated on their ability to generalize, providing a more honest assessment of their utility in real-world conservation and management scenarios.
Summary updated