Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 09-mapping.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,15 @@ g1 = ggplot() + geom_sf(data = nz, aes(fill = Median_income)) +
scale_x_continuous(breaks = c(170, 175))
g1
library(ggspatial)
# Refresh nz_elev to avoid 'external pointer is not valid' error
if (!exists("nz_elev")) {
nz_elev = terra::rast(system.file("raster/nz_elev.tif", package = "spDataLarge"))
}
ggplot() +
layer_spatial(nz_elev) +
tryCatch(layer_spatial(nz_elev), error = function(e) {
nz_elev <<- terra::rast(system.file("raster/nz_elev.tif", package = "spDataLarge"))
layer_spatial(nz_elev)
}) +
geom_sf(data = nz, fill = NA) +
annotation_scale() +
scale_x_continuous(breaks = c(170, 175)) +
Expand Down
2 changes: 1 addition & 1 deletion 12-spatial-cv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ Let's have a look at the final AUROC\index{AUROC}: the model's ability to discri
round(mean(score_spcv_svm$classif.auc), 2)
```

It appears that the GLM\index{GLM} (aggregated AUROC\index{AUROC} was `r score[resampling_id == "repeated_spcv_coords" & learner_id == "classif.log_reg", round(mean(classif.auc), 2)]`) is slightly better than the SVM\index{SVM} in this specific case.
It appears that the GLM\index{GLM} (aggregated AUROC\index{AUROC} was `r round(mean(score[score$resampling_id == "repeated_spcv_coords" & score$learner_id == "classif.log_reg", "classif.auc"]), 2)`) is slightly better than the SVM\index{SVM} in this specific case.
To guarantee an absolute fair comparison, one should also make sure that the two models use the exact same partitions -- something we have not shown here but have silently used in the background (see `code/12_cv.R` in the book's GitHub repository for more information).
To do so, **mlr3** offers the functions `benchmark_grid()` and `benchmark()` [see also https://mlr3book.mlr-org.com/chapters/chapter3/evaluation_and_benchmarking.html#sec-benchmarking, @bischl_applied_2024].
We will explore these functions in more detail in the Exercises.
Expand Down
Loading