-
Notifications
You must be signed in to change notification settings - Fork 0
/
score_forecasts.R
35 lines (35 loc) · 1.12 KB
/
score_forecasts.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
score_forecast_targets <- list(
# map forecasts to long format
tar_target(
forecast_cases_long,
quantiles_to_long(forecast_cases)
),
# score every available observation with all metrics
tar_target(
forecast_scores,
eval_forecasts(forecast_cases_long[!is.na(true_value)])
),
# calculate relative performance vs the single strain baseline
# baseline includes overdispersion etc so difference is just strain modelling
tar_target(
baseline_wis,
eval_forecasts(
forecast_cases_long[!is.na(true_value) & id == 0 & strains == 1],
metrics = "interval_score"
)[order(forecast_date, horizon)][
,
.(forecast_date, date, horizon, overdispersion, location, interval_score)
]
),
tar_target(
rwis,
merge(
eval_forecasts(
forecast_cases_long[!is.na(true_value) & strains == 2],
metrics = "interval_score"
)[order(id, forecast_date, date)],
baseline_wis[, baseline := interval_score][, interval_score := NULL],
by = c("forecast_date", "date", "horizon", "overdispersion", "location")
)[, c("rwis") := interval_score / baseline]
)
)