Skip to content

Commit

Permalink
Check cutoff BOYCE
Browse files Browse the repository at this point in the history
check cutoff for BOYCE for bm_OptimStat
+ Add temp_workdir as argument for bm_VariablesImportance
  • Loading branch information
HeleneBlt committed Jan 22, 2024
1 parent 998cf83 commit 5da9c6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions R/bm_FindOptimStat.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ bm_FindOptimStat <- function(metric.eval = 'TSS',
} else if (metric.eval == "MPA") {
cutoff <- ecospat.mpa(fit[which(obs == 1)], perc = mpa.perc)
}

if (!is.na(cutoff / 1000)) {
if (!is.na(cutoff / 1000) & cutoff <= 1000) {
EVAL <- presence.absence.accuracy(DATA, threshold = cutoff / 1000)
sensitivity <- EVAL$sensitivity * 100
specificity <- EVAL$specificity * 100
Expand Down
1 change: 1 addition & 0 deletions R/bm_RunModelsLoop.R
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ bm_RunModel <- function(model, run.name, dir.name = '.'
obs = data_sp[which(eval.lines.vec == FALSE)],
fit = g.pred[which(eval.lines.vec == FALSE)])
}
if (max(cross.validation$cutoff,na.rm = T) > 1000) {cat("\n*** Wrong values predicted, please be careful with the results fo this model")}
colnames(cross.validation)[which(colnames(cross.validation) == "best.stat")] <- "calibration"

stat.validation <- foreach(xx = metric.eval, .combine = "rbind") %do% {
Expand Down
5 changes: 3 additions & 2 deletions R/bm_VariablesImportance.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ bm_VariablesImportance <- function(bm.model,
nb.rep = 1,
# nb.cpu = 1,
seed.val = NULL,
do.progress = TRUE)
do.progress = TRUE,
temp_workdir = NULL)
{
args <- .bm_VariablesImportance.check.args(bm.model, expl.var, variables, method, nb.rep, seed.val, do.progress)
args <- .bm_VariablesImportance.check.args(bm.model, expl.var, variables, method, nb.rep, seed.val, do.progress,temp_workdir)
for (argi in names(args)) { assign(x = argi, value = args[[argi]]) }
rm(args)
## Test if prediction is computable
Expand Down

0 comments on commit 5da9c6a

Please sign in to comment.