
Confusion matrix over arbitrary labels (Geron Ch 3, morie.fn hmcfm)
Source:R/geron_ml2_native.R
morie_geron_confusion_matrix_labeled.RdMaps arbitrary labels to 0-based indices and then DELEGATES the
counting to morie_geron_confusion_matrix (the grcfm core), exactly
as the Python module does. Non-integer labels are ordered by their
string form, matching sorted(..., key=str).
Value
List with matrix, labels, accuracy, precision,
recall, f1, support, predicted_totals, macro_f1,
n_classes, estimate, n.
Details
This is the metrics core: hmeaf, hmf1 and hmmlb all read their precision/recall/F1 out of this same routine in Python.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_confusion_matrix_labeled(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
#>
#> $labels
#> [1] 0 1 2 3 4 5 6 7 8
#>
#> $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
#>
#> $predicted_totals
#> [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 C[i,j] = count(actual i, predicted j); counting delegated to grcfm"
#>