library(knitr)
library(pander)
library(ggplot2)

knitr::opts_chunk$set(comment="#>", results="markup",
                      fig.show='hold', fig.align="center", fig.height=8, fig.width=8,
                      warning=FALSE, cache=TRUE)

panderOptions("knitr.auto.asis", FALSE)

theme_set(
    theme_bw(base_size=14) + theme(
#        legend.position="bottom",
        legend.key=element_rect(colour=NA),
        plot.margin=unit(c(0.5, 0.5, 0.5, 0.5), "cm")
    )
)

set.seed(123)

PROJECT_DIR <- Sys.getenv('PROJECT_DIR')

Package classifiers Data

data(classifiers, package="AnalysisToolkit")
str(classifiers, list.len=2, vec.len=2, strict.width = "cut")

cPs <- classifiers[["classifier_points"]]
cCs <- classifiers[["classifier_curves"]]

Tabulate

glance() Binary Classifier Performance metrics

(lift_dl(rbind))(map(cPs, glance)) %>% 
    tibble::rownames_to_column("grader") %>% 
    arrange(desc(acc)) %>% 
    knitr::kable(digits=2)

glance() Continuous Classifier Performance metrics

(lift_dl(rbind))(map(cCs, glance_ClassifierCurve)) %>% 
    tibble::rownames_to_column("grader") %>% 
    arrange(desc(auc)) %>% 
    knitr::kable(digits=2)

Vizualize

Individual curves and points

# Make ggplot base and collect curves
roc_lines <- cCs %>% 
    map_dfr(roc, .id = "grader") %>% 
    {
        ggplot(., aes(x=x, y=y, col=grader)) +
            geom_line() +
            gg_roc_theme
    }

# collect points into a ggproto
roc_pts <- cPs %>% 
    map_dfr(roc, .id="grader") %>% 
    geom_point(data=.)

# Combine
roc_lines+roc_pts


mbadge/AnalysisToolkitR documentation built on May 27, 2019, 1:08 p.m.