Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cfm <- confusionMatrix(newvalidation$classe, valid_pred)
- ggplotConfusionMatrix <- function(m){
- mytitle <- paste("Accuracy", percent_format()(m$overall[1]),
- "Kappa", percent_format()(m$overall[2]))
- p <-
- ggplot(data = as.data.frame(m$table) ,
- aes(x = Reference, y = Prediction)) +
- geom_tile(aes(fill = log(Freq)), colour = "white") +
- scale_fill_gradient(low = "white", high = "green") +
- geom_text(aes(x = Reference, y = Prediction, label = percent(Freq/sum(Freq)))) +
- theme(legend.position = "none") +
- ggtitle(mytitle)
- return(p)
- }
- ggplotConfusionMatrix(cfm)
Add Comment
Please, Sign In to add comment