Skip to contents

Rows are truth, columns prediction. Labels are 0-based class indices, as in Python; the returned matrix is K x K in that same order.

Usage

morie_geron_confusion_matrix(y_true, y_pred, n_classes = NULL)

Arguments

y_true, y_pred

Integer class indices.

n_classes

Optional class count.

Value

List with matrix, accuracy, precision, recall, f1, support, macro_f1.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_confusion_matrix(V, V)
#> $matrix
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#>  [1,]    0    0    0    0    0    0    0    0    0
#>  [2,]    0    1    0    0    0    0    0    0    0
#>  [3,]    0    0    1    0    0    0    0    0    0
#>  [4,]    0    0    0    1    0    0    0    0    0
#>  [5,]    0    0    0    0    1    0    0    0    0
#>  [6,]    0    0    0    0    0    1    0    0    0
#>  [7,]    0    0    0    0    0    0    1    0    0
#>  [8,]    0    0    0    0    0    0    0    1    0
#>  [9,]    0    0    0    0    0    0    0    0    1
#> 
#> $accuracy
#> [1] 1
#> 
#> $precision
#> [1] NA  1  1  1  1  1  1  1  1
#> 
#> $recall
#> [1] NA  1  1  1  1  1  1  1  1
#> 
#> $f1
#> [1] 0 1 1 1 1 1 1 1 1
#> 
#> $support
#> [1] 0 1 1 1 1 1 1 1 1
#> 
#> $macro_f1
#> [1] 0.8888889
#> 
#> $n_classes
#> [1] 9
#> 
#> $estimate
#> [1] 1
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Confusion matrix"
#>