Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. cfm <- confusionMatrix(newvalidation$classe, valid_pred)
  2.  
  3.  
  4. ggplotConfusionMatrix <- function(m){
  5. mytitle <- paste("Accuracy", percent_format()(m$overall[1]),
  6. "Kappa", percent_format()(m$overall[2]))
  7. p <-
  8. ggplot(data = as.data.frame(m$table) ,
  9. aes(x = Reference, y = Prediction)) +
  10. geom_tile(aes(fill = log(Freq)), colour = "white") +
  11. scale_fill_gradient(low = "white", high = "green") +
  12. geom_text(aes(x = Reference, y = Prediction, label = percent(Freq/sum(Freq)))) +
  13. theme(legend.position = "none") +
  14. ggtitle(mytitle)
  15. return(p)
  16. }
  17.  
  18. ggplotConfusionMatrix(cfm)
Add Comment
Please, Sign In to add comment