R/cutoff.R

.Viz.ClassifierCurve.dx_cutoff <- function(x){
    metrics = c(accuracy='acc', sensitivity='sens', specificity='spec',
                PPV='ppv', NPV='npv')

    dx_dat <- map_df(metrics, function(metric){
        performance(x@pred, metric) %>%
            (function(perf) {
                data.frame(
                    x =      perf %>% slot("x.values") %>% unlist,
                    y =      perf %>% slot("y.values") %>% unlist)})
    },          .id='metric')

    dx_plt <- ggplot(dx_dat, aes(x=x, y=y, col=metric))+
        geom_line() +
        labs(title = paste('Performance by Threshold'),
             subtitle = '2017.06.23',
             x = 'Cutoff',
             y = 'Score')}
mbadge/AnalysisToolkitR documentation built on May 27, 2019, 1:08 p.m.