Description Usage Arguments Examples
Interactive Confusion Matrix
1 | fdPlotConfusionMatrix(x, class = "table table-bordered", digits = 3)
|
x |
confusion matrix with row and column names representing classes. It is expected that the rownames represent actual classes while column names represent the predicted classes |
class |
html class to style the confusion matrix table |
digits |
number of digits to display in the tooltip |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | library(flightdeck)
library(rpart)
mod <- rpart(Species ~ ., data = iris)
outcome <- as.character(attr(mod, 'ylevels')[mod$y])
pred <- predict(mod, type = "class")
# Example 1: Table
ctable <- table(outcome, pred)
if (interactive()){
fdRowBox(width = 6,
fdPlotConfusionMatrix(ctable),
title = 'Confusion Matrix',
footer = paste(
'Numbers in parantheses indicate % of observations',
'correctly classified. Hover for more details'
)
) %>%
fdPreview(wrap = 'none')
}
# Example 2: Matrix
cmat2 <- matrix(data = c(63, 3, 4, 33), nrow = 2, ncol = 2,
dimnames = list(
c('Actual Positive', 'Actual Negative'),
c('Predicted Positive', 'Predicted Negative')
)
)
fdPlotConfusionMatrix(cmat2) %>%
fdPreview
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.