confMatrix {SDMtune} | R Documentation |
Confusion Matrix
Description
Computes Confusion Matrixes for threshold values varying from 0 to 1.
Usage
confMatrix(model, test = NULL, th = NULL, type = NULL)
Arguments
model |
SDMmodel object. |
test |
SWD testing locations, if not provided it uses the training dataset. |
th |
numeric vector. If provided it computes the evaluation at the given
thresholds. Default is |
type |
character. The output type used for "Maxent" and "Maxnet" methods, possible values are "cloglog" and "logistic". |
Details
For models trained with the Maxent method the argument
type
can be: "raw", "logistic" and "cloglog".For models trained with the Maxnet method the argument
type
can be: "link", "exponential", "logistic" and "cloglog", see maxnet for more details.
Value
The Confusion Matrix for all the used thresholds.
Author(s)
Sergio Vignali
Examples
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
pattern = "grd",
full.names = TRUE)
predictors <- terra::rast(files)
# Prepare presence and background locations
p_coords <- virtualSp$presence
bg_coords <- virtualSp$background
# Create SWD object
data <- prepareSWD(species = "Virtual species",
p = p_coords,
a = bg_coords,
env = predictors,
categorical = "biome")
# Train a model
model <- train(method = "Maxnet",
data = data,
fc = "l")
# Get the confusion matrix for thresholds ranging from 0 to 1
cm <- confMatrix(model,
type = "cloglog")
head(cm)
tail(cm)
# Get the confusion matrix for a specific threshold
confMatrix(model,
type = "logistic",
th = 0.6)