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\Rtmp8CaQH3\file3f2429caed
#> rf tune
#> tune rf ■■ 4% | ETA: 35s
#> tune rf ■■■ 8% | ETA: 29s
#> tune rf ■■■■■ 12% | ETA: 27s
#> tune rf ■■■■■■ 16% | ETA: 26s
#> tune rf ■■■■■■■ 20% | ETA: 22s
#> tune rf ■■■■■■■■ 24% | ETA: 19s
#> tune rf ■■■■■■■■■ 28% | ETA: 17s
#> tune rf ■■■■■■■■■■■ 32% | ETA: 16s
#> tune rf ■■■■■■■■■■■■ 36% | ETA: 15s
#> tune rf ■■■■■■■■■■■■■ 40% | ETA: 14s
#> tune rf ■■■■■■■■■■■■■■ 44% | ETA: 13s
#> tune rf ■■■■■■■■■■■■■■■ 48% | ETA: 12s
#> tune rf ■■■■■■■■■■■■■■■■■ 52% | ETA: 11s
#> tune rf ■■■■■■■■■■■■■■■■■■ 56% | ETA: 10s
#> tune rf ■■■■■■■■■■■■■■■■■■■ 60% | ETA: 9s
#> tune rf ■■■■■■■■■■■■■■■■■■■■ 64% | ETA: 8s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■ 68% | ETA: 7s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■ 72% | ETA: 6s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■ 76% | ETA: 5s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■ 80% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■ 84% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 88% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 92% | ETA: 2s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 96% | ETA: 1s
#> evaluate rf ■■■■■■■■■■■ 32% | ETA: 2s
#> evaluate rf ■■■■■■■■■■■■■■ 44% | ETA: 2s
#> evaluate rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 88% | ETA: 0s
#> evaluate 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 1065 5590 0.16 0.991 0.885 0 0.84 0.991 0.991 0.41
#> CBI_rescale IMAE
#> 1 0.705 0.941
#>
#> @thresholds
#> max_kappa max_spec_sens no_omission equal_prevalence equal_sens_spec or10
#> 1 0.34 0.268 0.002 0.16 0.14 0.367
#>
#> @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.28 0.62 1 0.55 0.45 0 0.3 1 0.38 Inf
#> 3 0 0.34 0.68 1 0.62 0.38 0 0.33 1 0.32 1723.14
#> 4 ... ... ... ... ... ... ... ... ... ... ...
#> 205 1 0.63 0.92 0.5 1 0 0.5 1 0.91 0.08 Inf
#> 206 1 0.63 0.92 0.5 1 0 0.5 1 0.91 0.08 Inf
#> 207 1 0 0.84 0 1 0 1 NaN 0.84 0.16 NaN