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\Rtmp6rDfmf\file19843dbbb7a
#> rf tune
#> tune rf ■■ 4% | ETA: 1m
#> tune rf ■■■ 8% | ETA: 46s
#> tune rf ■■■■■ 12% | ETA: 34s
#> tune rf ■■■■■■ 16% | ETA: 28s
#> tune rf ■■■■■■■ 20% | ETA: 26s
#> tune rf ■■■■■■■■ 24% | ETA: 23s
#> tune rf ■■■■■■■■■ 28% | ETA: 20s
#> tune rf ■■■■■■■■■■■ 32% | ETA: 18s
#> tune rf ■■■■■■■■■■■■ 36% | ETA: 17s
#> tune rf ■■■■■■■■■■■■■ 40% | ETA: 16s
#> tune rf ■■■■■■■■■■■■■■ 44% | ETA: 14s
#> tune rf ■■■■■■■■■■■■■■■ 48% | ETA: 13s
#> tune rf ■■■■■■■■■■■■■■■■■ 52% | ETA: 12s
#> tune rf ■■■■■■■■■■■■■■■■■■ 56% | ETA: 11s
#> tune rf ■■■■■■■■■■■■■■■■■■■ 60% | ETA: 10s
#> tune rf ■■■■■■■■■■■■■■■■■■■■ 64% | ETA: 8s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■ 68% | ETA: 8s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■ 72% | ETA: 7s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■ 76% | ETA: 6s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■ 80% | ETA: 5s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■ 84% | ETA: 4s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■ 88% | ETA: 3s
#> tune rf ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 92% | 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 1062 5135 0.171 0.998 0.955 0 0.829 0.998 0.998 0.873
#> CBI_rescale IMAE
#> 1 0.937 0.966
#>
#> @thresholds
#> max_kappa max_spec_sens no_omission equal_prevalence equal_sens_spec or10
#> 1 0.791 0.388 0 0.17 0.452 0.862
#>
#> @tr_stats
#> treshold kappa CCR TPR TNR FPR FNR PPP NPP MCR OR
#> 1 0 0 0.17 1 0 1 0 0.17 NaN 0.83 NaN
#> 2 0 0.28 0.61 1 0.53 0.47 0 0.3 1 0.39 1190.34
#> 3 0 0.35 0.68 1 0.61 0.39 0 0.35 1 0.32 1649.56
#> 4 ... ... ... ... ... ... ... ... ... ... ...
#> 211 1 0.71 0.93 0.59 1 0 0.41 1 0.92 0.07 Inf
#> 212 1 0.71 0.93 0.59 1 0 0.41 1 0.92 0.07 Inf
#> 213 1 0 0.83 0 1 0 1 NaN 0.83 0.17 NaN