-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcv_starter.R
More file actions
32 lines (26 loc) · 779 Bytes
/
cv_starter.R
File metadata and controls
32 lines (26 loc) · 779 Bytes
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
library(tidyverse)
library(tsibble) # for creating nicer representation of monthly data
#library(efor)
library(furrr) # for running the forecasting in parallel
library(forecast) #provides forecast mehotds
library(prophet)
library(rsample)
sales_data <- sales_monthly %>%
mutate(date = yearmonth(date))
splits <- sales_data %>%
filter(iterate == "Article_A") %>%
rsample::rolling_origin(
initial = 24,
assess = 6,
cumulative = TRUE,
skip = 5
)
analysis(splits$splits[[2]])
cv_forecasts <- splits %>%
split(.$id) %>%
purrr::map_df(tf_grouped_forecasts_cv, func = ets, n_pred = 6)
# https://tidymodels.github.io/rsample/articles/Applications/Time_Series.html
cv_forecasts %>%
ggplot(aes(x = date, y = y )) +
geom_line() +
facet_wrap(~split_id)