confusion.matrix: Confusion Matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/confusion.matrix.R

Description

confusion.matrix calculates a confusion matrix.

Note: this method will exclude any missing data

Usage

1
confusion.matrix(obs, pred, threshold = 0.5)

Arguments

obs

a vector of observed values which must be 0 for absences and 1 for occurrences

pred

a vector of the same length as obs representing the predicted values. Values must be between 0 & 1 prepresenting a likelihood.

threshold

a single threshold value between 0 & 1

Value

Returns a confusion matrix (table) of class 'confusion.matrix' representing counts of true & false presences and absences.

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

See Also

auc, Kappa, omission, sensitivity, specificity, prop.correct, accuracy

Examples

1
2
3
4
5
6
#create some data
obs = c(sample(c(0,1),20,replace=TRUE),NA); obs = obs[order(obs)]
pred = runif(length(obs),0,1); pred = pred[order(pred)]

#calculate the confusion matrix
confusion.matrix(obs,pred,threshold=0.5)

Example output

    obs
pred  0 1
   0 13 0
   1  0 7
attr(,"class")
[1] "confusion.matrix"
Warning message:
In confusion.matrix(obs, pred, threshold = 0.5) :
  1 data points removed due to missing data

SDMTools documentation built on Jan. 11, 2020, 9:23 a.m.