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\Rtmpmcu61r\file66b8b79fd4
#> rf tune
presences <- prep$testing[prep$testing$pa == 1, ]
background <- prep$testing[prep$testing$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 319 1675 0.16 0.995 0.938 0 0.84 0.995 0.995 0.899
#> CBI_rescale IMAE
#> 1 0.949 0.963
#>
#> @thresholds
#> max_kappa max_spec_sens no_omission equal_prevalence equal_sens_spec or10
#> 1 0.58 0.242 0 0.159 0.347 0.744
#>
#> @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.34 0.68 1 0.62 0.38 0 0.33 1 0.32 520.82
#> 3 0 0.34 0.68 1 0.62 0.38 0 0.33 1 0.32 520.82
#> 4 ... ... ... ... ... ... ... ... ... ... ...
#> 175 1 0.77 0.95 0.67 1 0 0.33 1 0.94 0.05 Inf
#> 176 1 0.77 0.95 0.67 1 0 0.33 1 0.94 0.05 Inf
#> 177 1 0 0.84 0 1 0 1 NaN 0.84 0.16 NaN