R confusionMatrix()

1 개요[ | ]

R confusionMatrix()

2 전체 정보 조회[ | ]

library(caret) # confusionMatrix()
t <- as.table(rbind(c(231, 32), c(27, 54)))
dimnames(t) <- list(pred = c("abnormal", "normal"), truth = c("abnormal", "normal"))
confusionMatrix(t)
library(caret) # confusionMatrix()
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))
confusionMatrix(pred, truth)
library(caret) # confusionMatrix()
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)
confusionMatrix(xtab)

3 특정값만 추출 ★[ | ]

library(caret) # confusionMatrix()
t <- as.table(rbind(c(231, 32), c(27, 54)))
dimnames(t) <- list(pred = c("abnormal", "normal"), truth = c("abnormal", "normal"))
cm <- confusionMatrix(t)
cm$overall["Accuracy"]
cm$byClass["Sensitivity"]
cm$byClass["Specificity"]
cm$byClass["Specificity"]
cm$byClass["Precision"]
cm$byClass["Recall"]

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}