Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Last active January 28, 2019 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toyeiei/ce136771a9a12f5b2c3c8d7bb4352acd to your computer and use it in GitHub Desktop.
Save toyeiei/ce136771a9a12f5b2c3c8d7bb4352acd to your computer and use it in GitHub Desktop.
bayes application - cancer detection
# create confusion matrix
result <- matrix(c(99,1,495,9405), ncol=2, byrow=T)
colnames(result) <- c("Positive", "Negative")
rownames(result) <- c("Cancer", "No Cancer")
# see the table
result
sum(result) # n=10000
# overall accuracy of the medical test
(99 + 9405) / 10000 # 0.9504
# p(cancer|+) = true positive / all positives
99 / (99 + 495) # 0.1667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment