
Select models or algorithms by minimum values or Pareto optimality
Source:R/select.R
select_models.RdCombines the two selection rules used in practice:
Usage
select_models(
x,
rule = c("threshold", "pareto", "both"),
min_metrics = c(AUC = 0.8, TSS = 0.6),
max_metrics = NULL,
criteria = c(AUC = "max", MAE = "min"),
tol = 0,
override = NULL,
plot = interactive()
)Arguments
- x
A data.frame with one row per model and a
modelcolumn.- rule
"threshold","pareto"or"both"(see Details).- min_metrics
Named vector of minimum values (larger = better). Metrics that are not columns of
xare ignored with a message.- max_metrics
Named vector of maximum values for "lower is better" metrics, e.g.
c(MAEbal = 0.3): a model passes only if it does not exceed them. Together withmin_metricsthis lets the rule require both discrimination (AUC, TSS) and calibration (MAE, MAEbal).- criteria
Named character vector giving, for each Pareto criterion,
"max"(larger is better),"min"(smaller is better),"zero"(closer to 0 is better, e.g.bias) or"one"(closer to 1 is better, e.g.calibration_slope).- tol
Tolerance for Pareto ties; see
pareto_rank().- override
Optional character vector of model names to select by hand. The rules are still computed and reported.
- plot
Draw the selection (the first two criteria, full view and zoom; see
plot_selection()). Default: in interactive sessions.
Value
An object of class enm_selection (a data.frame): x with
columns pass, pareto, rank_mean and selected, sorted with the
selected models first. A criterion is only enforced through the
minimum/maximum values: a selected model can still be much worse than
the others on a criterion without a required value. Such models (worse
than the other selected models by more than 1.5 interquartile ranges,
with at least four selected) are reported when printing and in
attr(x, "outliers").
Details
"threshold"(default): keep every model reaching conventional minimum values on allmin_metrics(and not exceeding themax_metrics, for "lower is better" metrics such as MAEbal). This drops only clearly poor models and keeps several good ones for an ensemble. Typical values: AUC >= 0.8 ("excellent" discrimination; 0.7-0.8 "acceptable", Hosmer & Lemeshow 2000), TSS >= 0.6 ("substantial" agreement on the Landis & Koch 1977 scale), Boyce >= 0.5."pareto": keep only models on the Pareto front ofcriteria: no other model is better on one criterion without being worse on another. Stricter; usetolso that differences within sampling noise count as ties."both": models that reach the minimum values and are on the Pareto front (if none, those reaching the minimum values).
Choosing the rule. The Pareto front finds the best single models (the best trade-offs), not a group: a model can be on the front through one criterion alone (e.g. the best present-day fit) while being weak on another (e.g. hindcasts). For an ensemble, the minimum values usually give a more robust set; compare the candidate sets on independent data where you can.
Both rules are always computed and reported (pass, pareto), so you can
compare them; rule only decides which one fills selected. If no model
passes all minimum values, the Pareto front is used instead, with a
warning. rank_mean (mean rank over criteria, 1 = best) orders the
output.
Any table with a model column and metric columns works: the output of
evaluate_cv(), evaluate_models() or temporal_validation(), or
several of them joined with merge(), e.g. hold-out metrics together with
fossil validation.
Assumptions and limits. The default minimum values, AUC >= 0.8 and
TSS >= 0.6, are widely used conventions from the scales of Hosmer &
Lemeshow (2000) and Landis & Koch (1977), not limits validated for
distribution models: AUC and TSS depend on the evaluation design, the
background and the extent. Set min_metrics (e.g. stricter values) to
suit the study. What to vary. The rule, min_metrics and tol: a
selection that changes with small changes of these is not robust.
References
Konowalik, K., Nosol, A. (2021) Evaluation metrics and validation of presence-only species distribution models based on distributional maps with varying coverage. Scientific Reports 11, 1482. doi:10.1038/s41598-020-80062-1
Hosmer, D.W., Lemeshow, S. (2000) Applied Logistic Regression, 2nd edn. Wiley, New York.
Landis, J.R., Koch, G.G. (1977) The measurement of observer agreement for categorical data. Biometrics 33, 159-174. doi:10.2307/2529310
Examples
df <- data.frame(model = c("GLM", "GBM", "RF", "SRE"),
AUC = c(0.86, 0.88, 0.87, 0.71),
TSS = c(0.62, 0.65, 0.66, 0.38),
MAE = c(0.30, 0.27, 0.24, 0.41))
select_models(df) # minimum values
#> Model selection (rule: threshold)
#> Required values: AUC >= 0.8, TSS >= 0.6 | pass: GBM, RF, GLM
#> (conventional limits, not validated for distribution models; change them with min_metrics / max_metrics)
#> Pareto front (AUC:max, MAE:min; tol 0): GBM, RF
#> SELECTED: GBM, RF, GLM
#>
#> model AUC TSS MAE pass pareto rank_mean selected
#> GBM 0.88 0.65 0.27 TRUE TRUE 1.5 TRUE
#> RF 0.87 0.66 0.24 TRUE TRUE 1.5 TRUE
#> GLM 0.86 0.62 0.30 TRUE FALSE 3.0 TRUE
#> SRE 0.71 0.38 0.41 FALSE FALSE 4.0 FALSE
select_models(df, max_metrics = c(MAE = 0.3)) # ... and a maximum
#> Model selection (rule: threshold)
#> Required values: AUC >= 0.8, TSS >= 0.6, MAE <= 0.3 | pass: GBM, RF, GLM
#> (conventional limits, not validated for distribution models; change them with min_metrics / max_metrics)
#> Pareto front (AUC:max, MAE:min; tol 0): GBM, RF
#> SELECTED: GBM, RF, GLM
#>
#> model AUC TSS MAE pass pareto rank_mean selected
#> GBM 0.88 0.65 0.27 TRUE TRUE 1.5 TRUE
#> RF 0.87 0.66 0.24 TRUE TRUE 1.5 TRUE
#> GLM 0.86 0.62 0.30 TRUE FALSE 3.0 TRUE
#> SRE 0.71 0.38 0.41 FALSE FALSE 4.0 FALSE
select_models(df, rule = "pareto", tol = 0.01) # Pareto front
#> Model selection (rule: pareto)
#> Required values: AUC >= 0.8, TSS >= 0.6 | pass: RF, GBM, GLM
#> (conventional limits, not validated for distribution models; change them with min_metrics / max_metrics)
#> Pareto front (AUC:max, MAE:min; tol 0.01): RF
#> SELECTED: RF
#>
#> model AUC TSS MAE pass pareto rank_mean selected
#> RF 0.87 0.66 0.24 TRUE TRUE 1.5 TRUE
#> GBM 0.88 0.65 0.27 TRUE FALSE 1.5 FALSE
#> GLM 0.86 0.62 0.30 TRUE FALSE 3.0 FALSE
#> SRE 0.71 0.38 0.41 FALSE FALSE 4.0 FALSE