Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum length of time series for cross validation when using finetune? #4

Open
vidarsumo opened this issue Jun 6, 2024 · 0 comments

Comments

@vidarsumo
Copy link

I'm experimenting with nixtla_client_cross_validation(). When I'm using monthly data and some of the time series have few observations, I get an error when setting finetune_steps.

This works:

n_obs <- 37

# Create data
test_tbl <- tibble(
  unique_id = "id",
  ds = seq.Date(from = as.Date("2019-01-01"), length.out = n_obs, by = "month"),
  y = round(runif(n_obs, min = 10, max = 20))
)

timegpt_tscv <- nixtla_client_cross_validation(
  df         = test_tbl,
  h          = 12,
  id_col     = "unique_id",
  time_col   = "ds",
  target_col = "y",
  n_windows  = 1,
  finetune_steps = 10
)

This throws an error:

n_obs <- 36

# Create data
test_tbl <- tibble(
  unique_id = "id",
  ds = seq.Date(from = as.Date("2019-01-01"), length.out = n_obs, by = "month"),
  y = round(runif(n_obs, min = 10, max = 20))
)

timegpt_tscv <- nixtla_client_cross_validation(
  df         = test_tbl,
  h          = 12,
  id_col     = "unique_id",
  time_col   = "ds",
  target_col = "y",
  n_windows  = 1,
  finetune_steps = 10
)

Frequency chosen: MS
Error in `httr2::req_perform()`:
! HTTP 500 Internal Server Error.

Then I tried different frequency.
Using weekly time series, even when I cut one of them so it's only 3 weeks long, I get no error.

walmart_tbl <- timetk::walmart_sales_weekly %>% 
  select(id, Date, Weekly_Sales) %>% 
  set_names("unique_id", "ds", "y")

# make one time series short
walmart_short_tbl <- walmart_tbl %>% 
  filter(unique_id == "1_1") %>% 
  tail(3) %>% 
  bind_rows(
    walmart_tbl %>% 
      filter(!unique_id == "1_1")
  )

timegpt_tscv <- nixtla_client_cross_validation(
  df         = walmart_short_tbl,
  h          = 12,
  id_col     = "unique_id",
  time_col   = "ds",
  target_col = "y",
  n_windows  = 1,
  freq = "W-FRI",
  finetune_steps = 10
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant