Skip to content

Commit 8cd77ba

Browse files
authored
Merge pull request #69 from cmu-delphi/release_v1.1
Release_V1.1
2 parents 672fbc5 + 19e670c commit 8cd77ba

File tree

6 files changed

+58
-21
lines changed

6 files changed

+58
-21
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: forecast-eval
22
Title: Forecast Evaluation Dashboard
3-
Version: 0.1
3+
Version: 1.1
44
Authors@R: person("Kate", "Harwood",
55
role = c("cre")),
66
person("Chris", "Scott",

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,18 @@ To start a docker image of the shiny server locally:
3434
```bash
3535
> make start_dashboard
3636
```
37+
38+
# Releasing
39+
```
40+
git checkout dev
41+
git pull
42+
git checkout -b release_v1.0 origin/dev
43+
```
44+
Update version number in DESCRIPTION FILE
45+
```
46+
git add .
47+
git commit -m "Version 1.0 updates"
48+
git tag -a v1.0 -m "Version 1.0"
49+
git push origin release_v1.0
50+
git push origin v1.0
51+
```

Report/predictions.R

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ library(stringr)
77
create_prediction_cards = function(prediction_cards_filename){
88
start_date = today() - 100 * 7 # last 100 weeks
99

10-
forecasters = get_covidhub_forecaster_names()
10+
forecasters = get_covidhub_forecaster_names(designations = "primary")
1111
num_forecasters = length(forecasters)
1212
print(str_interp("Getting forecasts for ${num_forecasters} forecasters."))
1313

@@ -20,7 +20,10 @@ create_prediction_cards = function(prediction_cards_filename){
2020
error = function(e) cat(sprintf("%i. %s\n", i, e$message))
2121
)
2222
}
23-
23+
# Convert NULL to empty vector. Useful when a model has no forecasts,
24+
# resulting in a 404 and no forecast_dates.
25+
forecast_dates = lapply(forecast_dates,
26+
function(dates) if (is.null(dates)) Date() else dates)
2427
forecast_dates = lapply(forecast_dates, function(date) date[date >= start_date])
2528

2629
# Load data from previous run so we don't have to re-ingest / process it. This
@@ -43,19 +46,14 @@ create_prediction_cards = function(prediction_cards_filename){
4346
new_dates = list()
4447
for (i in 1:length(forecasters)) {
4548
given_dates = forecast_dates[[i]]
46-
# dates must be on a Sunday or Monday
47-
comparable_forecast_dates = given_dates[wday(given_dates) %in% c(1,2)]
48-
49-
# ...but only include Monday if both dates included
50-
comparable_forecast_dates = comparable_forecast_dates[!((comparable_forecast_dates + 1) %in% comparable_forecast_dates)]
5149
if(exists("seen_dates")){
5250
if(forecasters[[i]] %in% seen_dates$forecaster){
5351
seen_forecaster_dates = (seen_dates %>%
5452
filter(forecaster == forecasters[[i]]))$forecast_date
55-
comparable_forecast_dates = as_date(setdiff(comparable_forecast_dates, seen_forecaster_dates))
53+
given_dates = as_date(setdiff(given_dates, seen_forecaster_dates))
5654
}
5755
}
58-
new_dates[[i]] = comparable_forecast_dates
56+
new_dates[[i]] = given_dates
5957
}
6058

6159
names(new_dates) = forecasters
@@ -89,6 +87,15 @@ create_prediction_cards = function(prediction_cards_filename){
8987
filter(forecast_date >= start_date) %>%
9088
filter(!is.na(predictions_cards$target_end_date))
9189

90+
# Only accept forecasts made Monday or earlier
91+
predictions_cards = predictions_cards %>%
92+
filter(target_end_date - (forecast_date + 7 * ahead) >= -2)
93+
94+
# And only a forecaster's last forecast if multiple were made
95+
predictions_cards = predictions_cards %>%
96+
group_by(forecaster, geo_value, target_end_date, quantile, ahead, signal) %>%
97+
filter(forecast_date == max(forecast_date))
98+
9299
saveRDS(predictions_cards,
93100
file = prediction_cards_filename,
94101
compress = "xz")

Report/score.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ create_score_cards = function(prediction_cards_filepath, geo_type, signal_name =
5656
}
5757

5858
if(nrow(preds_to_eval) > 0){
59-
score_cards = evaluate_predictions(preds_to_eval,
59+
score_cards = evaluate_covid_predictions(preds_to_eval,
6060
err_measures,
61-
backfill_buffer = 0,
6261
geo_type = geo_type)
6362
# filter out scores that couldn't be evaluated to try to evaluate with
6463
# covidHubUtils.

dashboard/about-dashboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This dashboard was developed by [CMU Delphi](https://delphi.cmu.edu) in collaboration with the [Reich Lab](https://reichlab.io) and US [COVID-19 Forecast Hub](https://covid19forecasthub.org/) from UMass-Amherst, as part of the Forecast Evaluation Research Collaborative.
1+
This app collects and scores COVID-19 forecasts submitted to the CDC. The dashboard was developed by [CMU Delphi](https://delphi.cmu.edu) in collaboration with the [Reich Lab](https://reichlab.io) and US [COVID-19 Forecast Hub](https://covid19forecasthub.org/) from UMass-Amherst, as part of the Forecast Evaluation Research Collaborative.

dashboard/app.R

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,24 +322,40 @@ server <- function(input, output, session) {
322322

323323
filteredScoreDf$ahead = factor(filteredScoreDf$ahead, levels = c(1, 2, 3, 4),
324324
labels = c("Horizon: 1 Week", "Horizon: 2 Weeks", "Horizon: 3 Weeks", "Horizon: 4 Weeks"))
325-
p = ggplot(filteredScoreDf, aes(x = Week_End_Date, y = Score, color = Forecaster, linetype = Forecaster)) +
325+
p = ggplot(
326+
filteredScoreDf,
327+
aes(x = Week_End_Date, y = Score, color = Forecaster, shape = Forecaster)
328+
) +
326329
geom_line() +
327-
geom_point() +
330+
geom_point(size=2) +
328331
labs(x = "", y = "", title=titleText) +
329332
scale_x_date(date_labels = "%b %Y") +
330333
scale_y_continuous(limits = c(0,NA), labels = scales::comma) +
331334
facet_wrap(~ahead, ncol=1) +
332-
scale_color_manual(values = color_palette)
335+
scale_color_manual(values = color_palette) +
336+
theme_bw() +
337+
theme(panel.spacing=unit(0.5, "lines"))
333338

334339
if (scoreType == "coverage") {
335340
p = p + geom_hline(yintercept = .01 * as.integer(coverageInterval))
336341
}
337342
plotHeight = 550 + (length(horizon)-1)*100
338-
return(ggplotly(p + theme_bw() + theme(panel.spacing=unit(0.5, "lines")), tooltip = c("x", "y", "linetype"))
339-
%>% layout(height = plotHeight, legend = list(orientation = "h", y = -0.1), margin = list(t=90), height=500,
340-
hovermode = 'x unified', xaxis = list(title = list(text = "Target Date",
341-
standoff = 8L), titlefont = list(size = 12)))
342-
%>% config(displayModeBar = F))
343+
344+
finalPlot <-
345+
ggplotly(p,tooltip = c("x", "y", "shape")) %>%
346+
layout(
347+
height = plotHeight,
348+
legend = list(orientation = "h", y = -0.1),
349+
margin = list(t=90),
350+
height=500,
351+
hovermode = 'x unified',
352+
xaxis = list(
353+
title = list(text = "Target Date",standoff = 8L),
354+
titlefont = list(size = 12))
355+
) %>%
356+
config(displayModeBar = F)
357+
358+
return(finalPlot)
343359
}
344360

345361
# Create the plot for target variable ground truth

0 commit comments

Comments
 (0)