12.1 Terminology
supervised and unsupervised techniques
- supervised where there is training data
- unsupervised techniques such as clustering
response variables can be binary, categorical, integer, or otherwise numeric
predictive performance will be assessed using spatial cross-validation
- CV helps to detect overfitting
- caution: due to spatial autocorrelation, training and test datasets would not be independent, so spatial CV
12.1.1 Code Packages
library("dplyr")
library("future")
library("ggplot2")
library("lgr")
##
## Attaching package: 'lgr'
## The following object is masked from 'package:ggplot2':
##
## Layout
library("mlr3")
##
## Attaching package: 'mlr3'
## The following object is masked from 'package:terra':
##
## resample
library("mlr3learners")
# library(mlr3extralearners) #not available for R 4.3.0??
library("mlr3spatiotempcv")
library("mlr3tuning")
## Loading required package: paradox
library("mlr3viz")
library("pROC")
## Type 'citation("pROC")' for a citation.
##
## Attaching package: 'pROC'
## The following object is masked from 'package:colorspace':
##
## coords
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
library("progressr")
library("sf")
library("terra")
sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
##
## locale:
## [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
## [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
## [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
## [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
##
## time zone: UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] grid stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] progressr_0.13.0 pROC_1.18.2 mlr3viz_0.6.1
## [4] mlr3tuning_0.18.0 paradox_0.11.1 mlr3spatiotempcv_2.1.0
## [7] mlr3learners_0.5.6 mlr3_0.16.1 lgr_0.4.4
## [10] future_1.32.0 tmap_3.3-3 mapview_2.11.0
## [13] leaflet_2.1.2 colorspace_2.1-0 lubridate_1.9.2
## [16] forcats_1.0.0 stringr_1.5.0 purrr_1.0.1
## [19] readr_2.1.4 tibble_3.2.1 tidyverse_2.0.0
## [22] ggplot2_3.4.2 tidyr_1.3.0 dplyr_1.1.2
## [25] sp_2.0-0 spDataLarge_2.0.9 spData_2.2.2
## [28] terra_1.7-37 sf_1.0-13
##
## loaded via a namespace (and not attached):
## [1] DBI_1.1.3 tmaptools_3.1-1 leafpop_0.1.0
## [4] s2_1.1.4 rlang_1.1.1 magrittr_2.0.3
## [7] e1071_1.7-13 tidyterra_0.4.0 compiler_4.3.1
## [10] png_0.1-8 sfheaders_0.4.3 systemfonts_1.0.4
## [13] vctrs_0.6.3 pkgconfig_2.0.3 wk_0.7.3
## [16] crayon_1.5.2 fastmap_1.1.1 backports_1.4.1
## [19] ellipsis_0.3.2 lwgeom_0.2-13 leafem_0.2.0
## [22] labeling_0.4.2 utf8_1.2.3 rmarkdown_2.22
## [25] tzdb_0.4.0 bit_4.0.5 xfun_0.39
## [28] satellite_1.0.4 mlr3misc_0.12.0 cachem_1.0.8
## [31] jsonlite_1.8.5 highr_0.10 uuid_1.1-0
## [34] parallel_4.3.1 R6_2.5.1 bslib_0.5.0
## [37] stringi_1.7.12 RColorBrewer_1.1-3 parallelly_1.36.0
## [40] jquerylib_0.1.4 stars_0.6-1 Rcpp_1.0.10
## [43] bookdown_0.34 knitr_1.43 base64enc_0.1-3
## [46] leaflet.providers_1.9.0 timechange_0.2.0 tidyselect_1.2.0
## [49] rstudioapi_0.14 dichromat_2.0-0.1 abind_1.4-5
## [52] yaml_2.3.7 codetools_0.2-19 listenv_0.9.0
## [55] plyr_1.8.8 lattice_0.21-8 leafsync_0.1.0
## [58] withr_2.5.0 evaluate_0.21 units_0.8-2
## [61] proxy_0.4-27 pillar_1.9.0 KernSmooth_2.23-21
## [64] checkmate_2.2.0 stats4_4.3.1 generics_0.1.3
## [67] bbotk_0.7.2 vroom_1.6.3 hms_1.1.3
## [70] munsell_0.5.0 scales_1.2.1 globals_0.16.2
## [73] class_7.3-22 glue_1.6.2 tools_4.3.1
## [76] data.table_1.14.8 webshot_0.5.4 XML_3.99-0.14
## [79] crosstalk_1.2.0 raster_3.6-20 palmerpenguins_0.1.1
## [82] cli_3.6.1 brew_1.0-8 fansi_1.0.4
## [85] viridisLite_0.4.2 svglite_2.1.1 gtable_0.3.3
## [88] sass_0.4.6 digest_0.6.31 classInt_0.4-9
## [91] htmlwidgets_1.6.2 farver_2.1.1 htmltools_0.5.5
## [94] lifecycle_1.0.3 bit64_4.0.5