confMatrix: Confusion Matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/confMatrix.R

Description

Computes Confusion Matrixes for threshold values varying from 0 to 1.

Usage

1
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

Value

The Confusion Matrix for all the used thresholds.

Author(s)

Sergio Vignali

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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)

Example output

   _____  ____   __  ___ __
  / ___/ / __ \ /  |/  // /_ __  __ ____   ___
  \__ \ / / / // /|_/ // __// / / // __ \ / _ \
 ___/ // /_/ // /  / // /_ / /_/ // / / //  __/
/____//_____//_/  /_/ \__/ \__,_//_/ /_/ \___/  version 1.1.3

To cite this package in publications type: citation("SDMtune").
Extracting predictor information for presence locations...
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
Extracting predictor information for absence/background locations...
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
           th  tp   fp fn tn
1 0.000000000 400 5000  0  0
2 0.002786585 400 5000  0  0
3 0.003520421 400 4999  0  1
4 0.003616260 400 4998  0  2
5 0.003668746 400 4997  0  3
6 0.003691408 400 4996  0  4
            th tp fp  fn   tn
5203 0.9933962  0  5 400 4995
5204 0.9940262  0  4 400 4996
5205 0.9960225  0  3 400 4997
5206 0.9965570  0  2 400 4998
5207 0.9970066  0  1 400 4999
5208 1.0000000  0  0 400 5000
   th  tp  fp  fn   tn
1 0.6 126 410 274 4590

SDMtune documentation built on July 17, 2021, 9:06 a.m.