• R/O
  • SSH

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

コミットメタ情報

リビジョンc62d3ddc87005d128bf2a21002fa74d9f1c2e2c8 (tree)
日時2022-11-24 04:08:53
作者Lorenzo Isella <lorenzo.isella@gmai...>
コミッターLorenzo Isella

ログメッセージ

A parallelized and faster version of the code.

変更サマリ

差分

diff -r 5cabe85be9d9 -r c62d3ddc8700 R-codes/arima_simple1_parallel.R
--- a/R-codes/arima_simple1_parallel.R Wed Nov 23 19:37:34 2022 +0100
+++ b/R-codes/arima_simple1_parallel.R Wed Nov 23 20:08:53 2022 +0100
@@ -9,7 +9,6 @@
99 library(timetk) # for `tk_ts`
1010 library(tictoc)
1111 library(openxlsx)
12-## library(workflowsets)
1312 library(furrr)
1413
1514 tidymodels_prefer()
@@ -58,7 +57,9 @@
5857
5958
6059
60+tic()
6161
62+set.seed(1234)
6263
6364
6465 plan(multisession, workers = 4)
@@ -82,69 +83,46 @@
8283 pull(geo) |>
8384 su()
8485
85-ms_list <- c("DE", "AT", "FI")
86-
86+## ms_list <- c("DE", "AT", "FI")
8787
88-tic()
89-
90-out.total <- c()
88+ms_data <- future_map(ms_list, extract_ms_data )
9189
9290
93-set.seed(1234)
94-
95-
96-
97-
98-ms_data <- map(ms_list, extract_ms_data )
99-
100-
101-splits_parallel <- map( ms_data,
91+splits_parallel <- future_map( ms_data,
10292 function(x) time_series_split(x, assess = "3 months", cumulative = TRUE)
10393 )
10494
10595
10696
10797
108-model_fit_arima_parallel <- map(splits_parallel, function(x) arima_parallel(x))
98+model_fit_arima_parallel <- future_map(splits_parallel, function(x) arima_parallel(x))
10999
110100
111-model_table_parallel <-map(model_fit_arima_parallel, modeltime_table)
101+model_table_parallel <-future_map(model_fit_arima_parallel, modeltime_table)
112102
113-## calibration_table_parallel <- map2( model_table,
114-
115-## modeltime_calibrate(testing(splits)))
116103
117-testing_splits <- map(splits_parallel,testing )
104+testing_splits <- future_map(splits_parallel,testing )
118105
119-calibration_table_parallel <- map2( model_table_parallel,
106+calibration_table_parallel <- future_map2( model_table_parallel,
120107 testing_splits, modeltime_calibrate
121108 )
122109
123-refit_parallel <-map2( calibration_table_parallel, ms_data,
110+refit_parallel <-future_map2( calibration_table_parallel, ms_data,
124111 modeltime_refit
125112 )
126113
127114
128-new_forecast_parallel <- map2(refit_parallel, ms_data,
115+new_forecast_parallel <- future_map2(refit_parallel, ms_data,
129116 function(x,y) modeltime_forecast(x,h = "3 months", actual_data = y)
130117 )
131118
132119
133120
134-out.total <- map2_df(new_forecast_parallel, ms_list, extract_results)
135-
121+out.total <- future_map2_dfr(new_forecast_parallel, ms_list, extract_results)
136122
137123
138124
139-## out.total <- out.forecast_parallel |>
140-## filter(.key=="prediction") |>
141-## select(.index, .value) |>
142-## mutate(geo=sel_ms)
143-
144-
145-
146-
147- if (choose_log==1){
125+if (choose_log==1){
148126
149127 out.total <- out.total |>
150128 mutate(.value=exp(.value))
@@ -160,14 +138,8 @@
160138
161139 save_excel(out.total, fn)
162140
141+toc()
142+
163143 ######################################################################
164144
165-
166-
167-
168-
169-
170-
171-
172-
173145 print("So far so good")