File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ library(ggplot2 )
2+
3+ BINS <- 25
4+ COLORS <- c(" #a6cee3" , " #e31a1c" )
5+
6+ # Loads and cleans data.
7+ #
8+ # The `filename` argument must be a CSV file with column names
9+ # "p_hat", "y_true" for the predicted probabilties and ground truth labels.
10+ #
11+ get.data <- function (filename ) {
12+ data <- read.csv(filename )
13+ data $ y_true <- as.factor(data $ y_true )
14+ data
15+ }
16+
17+ # Returns a ggplot object. Input `data` frame must include column names
18+ # "p_hat", "y_true" for the predicted probabilties and ground truth labels.
19+ #
20+ get.plot <- function (data ) {
21+ ggplot(data , aes(p_hat , fill = y_true )) +
22+ geom_histogram(bins = BINS , position = " stack" , colour = " grey" ) +
23+ scale_fill_manual(values = COLORS , name = " Ground truth" ) +
24+ labs(x = " Predicted probability" , title = " " , y = " " )
25+ }
You can’t perform that action at this time.
0 commit comments