Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

confMatrix

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, default is NULL.

th

numeric vector, if provided it computes the evaluation at the given thresholds, default is NULL and it computes the evaluation for the unique predicted values at presence and absence/background locations.

type

character. The output type used for "Maxent" and "Maxnet" methods, possible values are "cloglog" and "logistic", default is NULL.

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 <- raster::stack(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)

SDMtune

Species Distribution Model Selection

v1.1.4
GPL-3
Authors
Sergio Vignali [aut, cre] (<https://orcid.org/0000-0002-3390-5442>), Arnaud Barras [aut] (<https://orcid.org/0000-0003-0850-6965>), Veronika Braunisch [aut] (<https://orcid.org/0000-0001-7035-4662>), Conservation Biology - University of Bern [fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.