Lab 08

MaxEnt and spatial model evaluation

Introducing a few more advanced SDM concepts

BIO597 Spatial Analysis of Biodiversity
Natural-history illustration of a pickerel frog on a mossy bank beside a Maine woodland stream.
This week

A classic presence/background model

ApproachHow the relationship is built
Our first SDMWe chose a simple temperature curve.
Random forestML learned a mapping between env correlates and presence/absence.
MaxEntA classical statistical model for fitting presence data to environmental evidence.

A foundational MaxEnt SDM paper: Phillips, Anderson & Schapire (2006).

A real MaxEnt fit

MaxEnt prediction projected across the landscape

Just like our previous examples, the fitted MaxEnt model can be used to predict suitability at unobserved locations.

Internally, a penalty discourages unnecessarily complex responses.

Relative suitability map for pickerel frogs fitted with elapid MaxentModel using 19 climate rasters and weighted presence/background records.
Accounting for observation bias when sampling background points

The background can influence the predictions

Two actual Maine background samples compare uniform sampling with sampling that favors warmer annual-mean-temperature cells.

Observations will be biased toward where humans usually go (near roads, in parks, where they think the organism will be), so it's important to replicate this bias as much as possible when sampling background points.

In the lab we will take mean annual temperature as a proxy for sampling bias, but in practice you might do something fancier.

Geographic sample weights

Sample weights change a point’s influence

Many neighboring observations can repeat similar information.

Distance-based weights give relatively isolated records more influence.

Pickerel-frog occurrences colored by distance-based sample weight, calculated in projected meters using elapid distance_weights.
Geographically aware splitting

Geographic splits withhold whole blocks

Keep an entire square in training or testing.

Lab08 uses alternating 50 km squares.

Teal training set. Coral test set. Nearby locations often share climate and sampling history.

Actual elapid checkerboard split of Maine modeling points, with entire 50 km blocks assigned to training in teal or testing in coral.
Evaluating robustness of test/train splits

Cross-validation rotates the test group

Presence/background points are split into 'K-fold' groups, and each group takes a turn as the withheld data. A new model is fit to each 'fold' of the data, and performance is evaluated as the average across N-folds.

Group AGroup BGroup C
Round 1TestTrainTrain
Round 2TrainTestTrain
Round 3TrainTrainTest

A group is often called a “fold.”

Two-fold spatial cross-validation

The checkerboard groups can swap roles

Two rounds swap the training and test roles of the same two checkerboard groups. The geometry and background sample stay fixed.

Each model predicts the group of locations it did not use for learning.

Leave-one-out (LOO) cross-validation is the logical extreme of k-fold

Buffered LOO controls for spatial auto-correlation

Hold out one observation as the test data.

Remove training points within 50 km.

Fit the SDM to all the remaining points.

Evaluate prediction accuracy for the one held-out point.

Repeat for another observation.

A held-out presence in coral has a 50 km exclusion circle. Training points outside the circle remain teal and excluded points appear gray.
Evaluating the frog model

Which sites does the model call suitable?

A cutoff at suitability score 0.5 separates predicted unsuitable from predicted suitable sites. Three recorded frogs lie above the cutoff, labeled TP, and one below, labeled FN. One background site lies above the cutoff, labeled FP, and three below, labeled TN.

True positives (TP): recorded frogs predicted suitable — 3 of 4.
False positives (FP): background sites predicted suitable — 1 of 4.

*For presence/background AUC, background serves as the “negative” class. These are not confirmed absences.

Comparing models across all cutoffs

Good predictions find frogs with fewer false alarms

Three illustrative ROC panels labeled Good, Medium and Bad (chance), with shaded AUC values 0.95, 0.75 and 0.50. Each plots true-positive rate against false-positive rate. The good curve approaches the upper-left corner, the medium curve bends moderately above the diagonal, and the bad curve follows the chance diagonal.

Moving the cutoff traces each ROC curve. Toward the upper left: more true positives, fewer false positives.

AUC = area under the curve. Larger areas mean better separation of recorded frogs from background.

Illustrative curves, not fitted results. “Good,” “medium” and “bad” describe these examples, not universal AUC thresholds.

High AUC isn't always 'better'

Spatially/environmentally informed splits can improve model generalizability

Evaluate usingAUCWhat is the model predicting?
Training records0.875Locations it already learned from
A random test split0.798Held-out points, often near training points
A spatial test split0.664Entire withheld geographic blocks

A higher random-test AUC can reflect an easier test, rather than better prediction in new areas.

Nearby points share climate and local patterns. Spatial splits reduce this overlap and help expose overfitting to those patterns.

Sources and visual credits

Further reading