Codes for ROC.^[See childRmd/_16ROC.Rmd file for other codes]

ROC

# library(OptimalCutpoints)
# https://tidymodels.github.io/yardstick/reference/roc_curve.html

roc_fit <- yardstick::roc_curve(mydata,
                                truth = "classification", 
                                estimate = "test",
                                na_rm = TRUE,
                                  options = list(
                                    smooth = FALSE,
                                    print.auc = TRUE,
                                    ret = c("all_coords")
                                    )
                                )

ggplot2::autoplot(roc_fit)
library(pROC)

m1 <- pROC::roc(mydata,
          "classification",
          "test",
          auc = TRUE, 
          ci = TRUE,
          # plot = TRUE,
          # percent=TRUE, 
          na.rm=TRUE,
          # smooth = TRUE,
          ret = "all_coords",
          # ret = "roc",
          quiet = FALSE,
          legacy.axes = TRUE,
          print.auc = TRUE,
          # xlab = "False Positive",
          # ylab = "True Positive"
          )
m1
pROC::roc(mydata,
          "polyp_rec",
          "size",
          auc = TRUE, 
          ci = TRUE,
          # plot = TRUE,
          # percent=TRUE, 
          na.rm=TRUE,
          # smooth = TRUE,
          # ret = "all_coords",
          ret = "roc",
          quiet = FALSE,
          legacy.axes = TRUE,
          print.auc = TRUE,
          # xlab = "False Positive",
          # ylab = "True Positive"
          )
which.max(m1$youden)
m1[which.max(m1$youden),]
roc_obj <- pROC::roc(polyp_rec ~ size,
          data = mydata,
          auc = TRUE,
          ci = TRUE,
          plot = TRUE,
          # percent=TRUE, 
          na.rm=TRUE,
          # smooth = TRUE,
          # ret = "all_coords",
          ret = "roc",
          quiet = FALSE,
          legacy.axes = TRUE,
          print.auc = TRUE,
          xlab = "False Positive",
          ylab = "True Positive"
          )
# devtools::install_github("sachsmc/plotROC")
library(plotROC)
# shiny_plotROC()


sbalci/histopathology-template documentation built on June 29, 2023, 5:52 a.m.