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(data$out_dir[[1]], "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 chg with algorithms: rf
#> out_dir is C:/temp/nige\RtmpCQ11ZL\file30043e5a2805
#> rf tune
#> tune rf ■■■■■ 13% | ETA: 8s
#> tune rf ■■■■■■ 17% | ETA: 7s
#> tune rf ■■■■■■■■ 22% | ETA: 6s
#> tune rf ■■■■■■■■■ 26% | ETA: 6s
#> tune rf ■■■■■■■■■■ 30% | ETA: 5s
#> tune rf ■■■■■■■■■■■ 35% | ETA: 5s
#> tune rf ■■■■■■■■■■■■■ 39% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■ 43% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■■ 48% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■ 52% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■ 57% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■ 61% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■ 65% | ETA: 2s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■ 70% | ETA: 2s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■ 74% | ETA: 2s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■ 78% | ETA: 1s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■ 83% | ETA: 1s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 87% | ETA: 1s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 91% | ETA: 1s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 96% | ETA: 0s
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 92 5103 0.018 0.93 0.282 0 0.982 0.93 0.93 0.964
#> CBI_rescale IMAE
#> 1 0.982 0.794
#>
#> @thresholds
#> max_kappa max_spec_sens no_omission equal_prevalence equal_sens_spec or10
#> 1 0.92 0.39 0.302 0.018 0.49 0.394
#>
#> @tr_stats
#> treshold kappa CCR TPR TNR FPR FNR PPP NPP MCR OR
#> 1 0 0 0.02 1 0 1 0 0.02 NaN 0.98 NaN
#> 2 0 0 0.1 1 0.09 0.91 0 0.02 1 0.9 Inf
#> 3 0 0.01 0.16 1 0.14 0.86 0 0.02 1 0.84 Inf
#> 4 ... ... ... ... ... ... ... ... ... ... ...
#> 444 1 0.08 0.98 0.04 1 0 0.96 1 0.98 0.02 Inf
#> 445 1 0.08 0.98 0.04 1 0 0.96 1 0.98 0.02 Inf
#> 446 1 0 0.98 0 1 0 1 NaN 0.98 0.02 NaN