Calculates confusion matrix for given cutoff

confusion_matrix(probs, observed, cutoff)

Arguments

probs

numeric, vector with probabilities given by model

observed

numeric, vector with actual values from outcome, either 0 or 1

cutoff

numeric, single value denoting cutoff/threshold

Value

object of class confussion_matrix It is a list with following fields:

  • tpnumber of True Positives

  • fpnumber of False Positives

  • tnnumber of True Negatives

  • fnnumber of False Negatives

Examples


probs <- rnorm(20, 0.4, 0.1)
observed <- round(runif(20))

confusion_matrix(probs, observed, 0.5)
#> $tp
#> [1] 1
#> 
#> $fp
#> [1] 2
#> 
#> $tn
#> [1] 9
#> 
#> $fn
#> [1] 8
#> 
#> attr(,"class")
#> [1] "confusion_matrix"