Returns various evaluation metrics from predicts::pa_evaluate()
and
flexsdm::sdm_eval()
.
Arguments
- m
SDM result within
tune_sdm()
- p_test
Presence test data generated within
tune_sdm()
- b_test
Background test data generated within
tune_sdm()
- do_gc
Logical. Run
base::rm(list = ls)
andbase::gc()
at end of function? Useful when running SDMs for many, many taxa, especially if done in parallel. Note, actually useesrm(list = ls(pattern = "^[^e$]"))
.- ...
Passed to both
terra::predict()
andpredicts::pa_evaluate()
Value
paModelEvaluation (see predicts::pa_evaluate()
) with extra metrics
from flexsdm::sdm_eval()
: AUC as auc_po_flexsdm; BOYCE as CBI; CBI_rescale
(CBI is -1 to 1, CBI_rescale is 0 to 1); and IMAE.
Examples
out_dir <- file.path(system.file(package = "envSDM"), "examples")
source(fs::path(out_dir, "tune_sdm_ex.R")) # make sure following prep file exists
prep <- rio::import(fs::path(out_dir, "acaule", "prep.rds")
, trust = TRUE
)
model <- tune_sdm(prep = prep
, out_dir = FALSE
, return_val = "object"
, algo = "rf"
, trees = 500
, mtry = 2
, nodesize = 1
, keep_model = TRUE
)
#> tuning acaule with algorithms: rf
#> out_dir is C:/temp/nige\RtmpGkEZkx\file226c32f26114
#> rf tune
#> tune rf ■■ 4% | ETA: 39s
#> tune rf ■■■■ 9% | ETA: 31s
#> tune rf ■■■■■ 13% | ETA: 29s
#> tune rf ■■■■■■ 17% | ETA: 27s
#> tune rf ■■■■■■■■ 22% | ETA: 23s
#> tune rf ■■■■■■■■■ 26% | ETA: 20s
#> tune rf ■■■■■■■■■■ 30% | ETA: 17s
#> tune rf ■■■■■■■■■■■ 35% | ETA: 16s
#> tune rf ■■■■■■■■■■■■■ 39% | ETA: 15s
#> tune rf ■■■■■■■■■■■■■■ 43% | ETA: 13s
#> tune rf ■■■■■■■■■■■■■■■ 48% | ETA: 12s
#> tune rf ■■■■■■■■■■■■■■■■■ 52% | ETA: 10s
#> tune rf ■■■■■■■■■■■■■■■■■■ 57% | ETA: 10s
#> tune rf ■■■■■■■■■■■■■■■■■■■ 61% | ETA: 9s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■ 65% | ETA: 8s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■ 70% | ETA: 6s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■ 74% | ETA: 5s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■ 78% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■ 83% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 87% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 91% | ETA: 2s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 96% | ETA: 1s
presences <- prep$testing$testing[[1]][prep$testing$testing[[1]]$pa == 1, ]
background <- prep$testing$testing[[1]][prep$testing$testing[[1]]$pa == 0, ]
evaluate_sdm(model$tune_rf$m[[1]]
, p_test = presences
, b_test = background
)
#> @stats
#> np na prevalence auc cor pcor ODP auc_po auc_po_flexsdm CBI
#> 1 1065 5609 0.16 0.992 0.883 0 0.84 0.992 0.992 0.298
#> CBI_rescale IMAE
#> 1 0.649 0.944
#>
#> @thresholds
#> max_kappa max_spec_sens no_omission equal_prevalence equal_sens_spec or10
#> 1 0.302 0.074 0.022 0.16 0.114 0.318
#>
#> @tr_stats
#> treshold kappa CCR TPR TNR FPR FNR PPP NPP MCR OR
#> 1 0 0 0.16 1 0 1 0 0.16 NaN 0.84 NaN
#> 2 0 0.25 0.58 1 0.51 0.49 0 0.28 1 0.42 Inf
#> 3 0 0.33 0.67 1 0.61 0.39 0 0.33 1 0.33 Inf
#> 4 ... ... ... ... ... ... ... ... ... ... ...
#> 195 1 0.63 0.92 0.51 1 0 0.49 1 0.91 0.08 Inf
#> 196 1 0.63 0.92 0.51 1 0 0.49 1 0.91 0.08 Inf
#> 197 1 0 0.84 0 1 0 1 NaN 0.84 0.16 NaN