Skip to content

Commit b789be8

Browse files
committed
checks in R functions for visualizing score/ground-truth distribution
1 parent 4a1f7f2 commit b789be8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

calibration.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
}

0 commit comments

Comments
 (0)