confusion.matrix: Create a confusion matrix

View source: R/confusion.matrix.R

confusion.matrixR Documentation

Create a confusion matrix

Description

Create a confusion matrix from actual and predicted values. Note that this function follows the convention of placing "Predicted" as the row variable and "Actual/Correct" as the column variable for the returned contingency table. This is unlikely to be a compatible format with other packages that use the reverse convention for predicted/actual.

Usage

confusion.matrix(
  actual,
  predicted,
  actual.positive.fn = function(actual) {
     ifelse(actual == 1, 1, 0)
 },
  predicted.positive.fn = function(predicted) {
     ifelse(predicted == 1, 1, 0)
 }
)

Arguments

actual

A vector of values identifying the actual value (default 0,1 or use actual.positive.fn to convert)

predicted

A vector of values identifying the predicted value (default 0,1 or use predicted.positive.fn to convert)

actual.positive.fn

A function that takes values present in actual and converts them to 0,1

predicted.positive.fn

A function that takes values in predicted and converts them to 0,1

Value

A 2x2 matrix showing agreement between actual and predicted.


burrm/lolcat documentation built on Sept. 15, 2023, 11:35 a.m.