@@ -38,20 +38,30 @@ export_test_result <- function(test_data, coef_data, indicator, signal,
38
38
geo = geo , value_type = value_type , model_mode = FALSE )
39
39
40
40
signal_info <- str_interp(" indicator ${indicator} signal ${signal} geo ${geo} value_type ${value_type}" )
41
+
42
+ components <- c(indicator , signal , signal_suffix )
43
+ signal_dir = paste0(
44
+ # Drop any empty strings.
45
+ paste(components [components != " " ], collapse = " _" ),
46
+ )
47
+
41
48
if (nrow(test_data ) == 0 ) {
42
49
warning(str_interp(" No test data available for ${signal_info}" ))
43
50
} else {
44
51
msg_ts(str_interp(" Saving predictions to disk for ${signal_info} " ))
45
52
pred_output_file <- str_interp(" prediction_${base_name}" )
46
- write_csv(test_data , file.path(export_dir , pred_output_file ))
53
+
54
+ prediction_col <- colnames(test_data )[grepl(" ^predicted" , colnames(test_data ))]
55
+ expected_col <- c(" time_value" , " issue_date" , " lag" , " target_date" , " wis" , prediction_col )
56
+ write_csv(test_data [expected_col ], file.path(export_dir , signal_dir , pred_output_file ))
47
57
}
48
58
49
59
if (nrow(coef_data ) == 0 ) {
50
60
warning(str_interp(" No coef data available for ${signal_info}" ))
51
61
} else {
52
62
msg_ts(str_interp(" Saving coefficients to disk for ${signal_info}" ))
53
- coef_output_file <- str_interp(" coefs_${base_name}" )
54
- write_csv(coef_data , file.path(export_dir , coef_output_file ))
63
+ coef_output_file <- str_interp(" coefs_${base_name}" )
64
+ write_csv(coef_data , file.path(export_dir , signal_dir , coef_output_file ))
55
65
}
56
66
}
57
67
0 commit comments