predict_sdm {caretSDM} | R Documentation |
Predict SDM models in new data
Description
This function projects SDM models to new scenarios
Usage
predict_sdm(m,
scen = NULL,
metric = "ROC",
th = 0.9,
tp = "prob",
ensembles = TRUE,
file = NULL,
add.current = TRUE)
get_predictions(i)
get_ensembles(i)
Arguments
m |
A |
scen |
A |
metric |
A character containing the metric in which the |
th |
Thresholds for metrics. Can be numeric or a function. |
tp |
Type of output to be retrieved. See details. |
ensembles |
Boolean. Should ensembles be calculated? If |
file |
File to sabe predictions. |
add.current |
If current scenario is not available, predictors will be used as the current scenario. |
i |
A |
Details
tp
is a parameter to be passed on caret to retrieve either the probabilities of classes
(tp="prob") or the raw output (tp="raw"), which could vary depending on the algorithm used, but
usually would be on of the classes (factor vector with presences and pseudoabsences).
When ensembles
is set to TRUE
, three ensembles are currently implemented.
mean_occ_prob is the mean occurrence probability, which is a simple mean of predictions,
wmean_AUC is the same mean_occ_prob, but weighted by AUC, and committee_avg is the committee
average, as known as majority rule, where predictions are binarized and then a mean is obtained.
get_predictions
returns the list
of all predictions to all scenarios, all species,
all algorithms and all repetitions. Useful for those who wish to implement their own ensemble
methods.
get_ensembles
returns a matrix
of data.frame
s, where each column is a
scenario and each row is a species.
scenarios_names
returns the scenarios names in a sdm_area
or input_sdm
object.
get_scenarios_data
returns the data from scenarios in a sdm_area
or
input_sdm
object.
Value
A input_sdm
or a predictions
object.
Author(s)
Luíz Fernando Esser (luizesser@gmail.com) https://luizfesser.wordpress.com
See Also
sdm_area input_sdm mean_validation_metrics
Examples
# Create sdm_area object:
set.seed(1)
sa <- sdm_area(parana, cell_size = 100000, crs = 6933)
# Include predictors:
sa <- add_predictors(sa, bioc) |> select_predictors(c("bio1", "bio12"))
# Include scenarios:
sa <- add_scenarios(sa)
# Create occurrences:
oc <- occurrences_sdm(occ, crs = 6933) |> join_area(sa)
# Create input_sdm:
i <- input_sdm(oc, sa)
# Pseudoabsence generation:
i <- pseudoabsences(i, method="random", n_set=2)
# Custom trainControl:
ctrl_sdm <- caret::trainControl(method = "boot",
number = 1,
repeats = 1,
classProbs = TRUE,
returnResamp = "all",
summaryFunction = summary_sdm,
savePredictions = "all")
# Train models:
i <- train_sdm(i, algo = c("naive_bayes"), ctrl=ctrl_sdm) |>
suppressWarnings()
# Predict models:
i <- predict_sdm(i, th = 0.8)
i