-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_loss.R
More file actions
21 lines (17 loc) · 871 Bytes
/
plot_loss.R
File metadata and controls
21 lines (17 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
list.of.packages <- c("data.table", "ggplot2", "stringr")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages, require, character.only=T)
setwd("~/git/FCDO-Humanitarian-Forecasting-Presentation/")
dat = read.delim("best_loss.txt", sep=" ", header=F)
dat = dat[,c("V2", "V3", "V5")]
dat$V2 = as.numeric(gsub("]", "", dat$V2))
names(dat) = c("epoch", "set", "loss")
valid = subset(dat, set=="VALID")
min.valid.epoch = valid$epoch[which.min(valid$loss)]
message(min.valid.epoch, "/", max(valid$epoch))
test.loss.at.epoch = dat$loss[which(dat$set=="TEST" & dat$epoch==min.valid.epoch)]
message(test.loss.at.epoch)
ggplot(dat) +
geom_vline(aes(xintercept=min.valid.epoch), linetype="dashed") +
geom_line(aes(x=epoch, y=loss, group=set, color=set))