Confusion matrix as a table
Conversion functions for class confusionMatrix
## S3 method for class 'confusionMatrix' as.matrix(x, what = "xtabs", ...)
x |
an object of class |
what |
data to convert to matrix. Either |
... |
not currently used |
For as.table
, the cross-tabulations are saved. For as.matrix
, the three object types are saved in matrix format.
A matrix or table
Max Kuhn
################### ## 2 class example lvs <- c("normal", "abnormal") truth <- factor(rep(lvs, times = c(86, 258)), levels = rev(lvs)) pred <- factor( c( rep(lvs, times = c(54, 32)), rep(lvs, times = c(27, 231))), levels = rev(lvs)) xtab <- table(pred, truth) results <- confusionMatrix(xtab) as.table(results) as.matrix(results) as.matrix(results, what = "overall") as.matrix(results, what = "classes") ################### ## 3 class example xtab <- confusionMatrix(iris$Species, sample(iris$Species)) as.matrix(xtab)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.