Skip to contents

This function produces a confusion matrix given a set of observed and predicted values.

Usage

confusion_matrix(true, pred)

Source

See Wiki page for further information.

Arguments

true

a vector (or a matrix) of observed values. If a matrix is provided, a multi-response is assumed

pred

a vector (or a matrix) of predicted values

Value

the confusion matrix, a table reporting the number of samples for different groups. The matrix element (i, j) represents the number of samples known to be in group i and predicted in group j.

Details

The confusion matrix is a specific table that reports the classification accuracy of an algorithm. In this implementation, a confusion matrix C has rows reporting instances of the actual classes, while columns report instances of the predicted classes.

Author

Alessandro Barberis