bm_FindOptimStat {biomod2} | R Documentation |
Calculate the best score according to a given evaluation method
Description
This internal biomod2 function allows the user to find the threshold to convert continuous values into binary ones leading to the best score for a given evaluation metric.
Usage
bm_FindOptimStat(
metric.eval = "TSS",
obs,
fit,
nb.thresh = 100,
threshold = NULL
)
get_optim_value(metric.eval)
bm_CalculateStat(misc, metric.eval = "TSS")
Arguments
metric.eval |
a |
obs |
a |
fit |
a |
nb.thresh |
an |
threshold |
(optional, default |
misc |
a |
Details
Please refer to BIOMOD_Modeling
to get more information about these
evaluation metrics.
Note that if a value is given to threshold
, no optimisation will be done., and
only the score for this threshold will be returned.
Value
A 1
row x 5
columns data.frame
containing :
metric.eval
: the chosen evaluation metriccutoff
: the associated cut-off used to transform the continuous values into binarysensitivity
: the sensibility obtained on fitted values with this thresholdspecificity
: the specificity obtained on fitted values with this thresholdbest.stat
: the best score obtained for the chosen evaluation metric
Author(s)
Damien Georges
See Also
BIOMOD_Modeling
, bm_RunModelsLoop
,
BIOMOD_EnsembleModeling
Other Secundary functions:
bm_BinaryTransformation()
,
bm_CVnnet()
,
bm_CrossValidation()
,
bm_MakeFormula()
,
bm_PlotEvalBoxplot()
,
bm_PlotEvalMean()
,
bm_PlotRangeSize()
,
bm_PlotResponseCurves()
,
bm_PlotVarImpBoxplot()
,
bm_PseudoAbsences()
,
bm_RunModelsLoop()
,
bm_SRE()
,
bm_SampleBinaryVector()
,
bm_SampleFactorLevels()
,
bm_VariablesImportance()
Examples
## Generate a binary vector
vec.a <- sample(c(0, 1), 100, replace = TRUE)
## Generate a 0-1000 vector (random drawing)
vec.b <- runif(100, min = 0, max = 1000)
## Generate a 0-1000 vector (biased drawing)
BiasedDrawing <- function(x, m1 = 300, sd1 = 200, m2 = 700, sd2 = 200) {
return(ifelse(x < 0.5, rnorm(1, m1, sd1), rnorm(1, m2, sd2)))
}
vec.c <- sapply(vec.a, BiasedDrawing)
vec.c[which(vec.c < 0)] <- 0
vec.c[which(vec.c > 1000)] <- 1000
## Find optimal threshold for a specific evaluation metric
bm_FindOptimStat(metric.eval = 'TSS', fit = vec.b, obs = vec.a)
bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, nb.thresh = 100)
bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, threshold = 280)