-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_post_mortem.R
118 lines (114 loc) · 3.65 KB
/
run_post_mortem.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#' Pipeline for Post-Mortem
#'
#' This pipeline is designed to conduct a comprehensive post-mortem analysis of
#' our previous forecast by performing a series of computations and data
#' manipulations. Its purpose is to thoroughly evaluate the accuracy and
#' performance of the forecasted results and provide valuable insights for
#' retrospective examination.
library(targets)
# Set target options:
tar_option_set(
packages = c(
"xts", "lubridate", "dplyr", "tidyr", "data.table", "tibble",
"jsonlite", "styler", "visNetwork"
),
memory = "transient",
garbage_collection = TRUE
)
options(dplyr.summarise.inform = FALSE)
# Execute files stored in R/
tar_source(files = "R")
# Pipeline
list(
tar_target(
name = data_info_file,
command = "data.yaml",
format = "file"
),
tar_target(
name = challenges_file,
command = "challenges.yaml",
format = "file"
),
tar_target(
name = submitted_models_file,
command = "submitted_models.yaml",
format = "file"
),
tar_target(
name = data_info,
command = yaml::read_yaml(data_info_file),
),
tar_target(
name = challenges,
command = yaml::read_yaml(challenges_file),
),
tar_target(
name = data,
command = read_data_from_s3(challenges, data_info),
),
tar_target(
name = submitted_models,
command = yaml::read_yaml(submitted_models_file),
),
tar_target(
name = past_submissions_gas,
command = create_table_past_submissions(submitted_models, "GAS", submissions_folder = "Submissions", by_entry = FALSE)
),
tar_target(
name = past_submissions_gas_by_entry,
command = create_table_past_submissions(submitted_models, "GAS", submissions_folder = "Submissions", by_entry = TRUE)
),
tar_target(
name = recent_data_gas,
command = get_recent_data(data, challenges, submitted_models, "GAS")
),
tar_target(
name = past_errors_gas,
command = get_residuals_past_months(past_submissions_gas, recent_data_gas)
),
tar_target(
name = past_errors_gas_by_entry,
command = get_residuals_past_months(past_submissions_gas_by_entry, recent_data_gas)
),
tar_target(
name = past_submissions_oil,
command = create_table_past_submissions(submitted_models, "OIL", submissions_folder = "Submissions", by_entry = FALSE)
),
tar_target(
name = past_submissions_oil_by_entry,
command = create_table_past_submissions(submitted_models, "OIL", submissions_folder = "Submissions", by_entry = TRUE)
),
tar_target(
name = recent_data_oil,
command = get_recent_data(data, challenges, submitted_models, "OIL")
),
tar_target(
name = past_errors_oil,
command = get_residuals_past_months(past_submissions_oil, recent_data_oil)
),
tar_target(
name = past_errors_oil_by_entry,
command = get_residuals_past_months(past_submissions_oil_by_entry, recent_data_oil)
),
tar_target(
name = past_submissions_electricity,
command = create_table_past_submissions(submitted_models, "ELECTRICITY", submissions_folder = "Submissions", by_entry = FALSE)
),
tar_target(
name = past_submissions_electricity_by_entry,
command = create_table_past_submissions(submitted_models, "ELECTRICITY", submissions_folder = "Submissions", by_entry = TRUE)
),
tar_target(
name = recent_data_electricity,
command = get_recent_data(data, challenges, submitted_models, "ELECTRICITY")
),
tar_target(
name = past_errors_electricity,
command = get_residuals_past_months(past_submissions_electricity, recent_data_electricity)
),
tar_target(
name = past_errors_electricity_by_entry,
command = get_residuals_past_months(past_submissions_electricity_by_entry, recent_data_electricity)
)
)