Learn R Programming

SDMtune (version 1.1.0)

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 test locations, if not provided it uses the train 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.

Value

The Confusion Matrix for all the used thresholds.

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.

Examples

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataLab