Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mat <- matrix(0, nrow = length(y_pred), ncol = length(y_true), dimnames = list(c("Prediction"), c("Reference")))
- for(i in 1:length(y_pred)) {
- matrix[[y_pred[i]]][[y_true[i]]] =+ 1
- }
- dbl_TP <- 0
- dbl_TN <- 0
- for(i in 1:length(y_pred)) {
- for(j in 1:length(y_true)) {
- if(i==j) {
- dbl_TP =+ matrix[i][j]
- } else {
- dbl_TN =+ matrix[i][j]
- }
- }
- }
- dbl_accuracy = (dbl_Tp + dbl_TN) / length(y_pred)
- table = data.table(mat, keep.rownames = TRUE)
- return( c(table, dbl_accuracy))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement