Skip to content

Commit

Permalink
Revert "implement future.apply in forecast.mdl_df"
Browse files Browse the repository at this point in the history
This reverts commit d49e0ab.

It causes issues with evaluation flow, and it is more valuable to parallelise across series rather than models
  • Loading branch information
davidtedfordholt authored and mitchelloharawild committed Sep 28, 2020
1 parent 401eb23 commit f4c96de
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions R/forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,38 +105,13 @@ forecast.mdl_df <- function(object, new_data = NULL, h = NULL,
object <- bind_new_data(object, new_data)
}

object <- tidyr::pivot_longer(object, !!mdls, names_to = ".model", values_to = ".mdl")

# Evaluate forecasts
if(is_attached("package:future")){
require_package("future.apply")

object[[".fc"]] <- future.apply::future_mapply(
FUN = forecast,
object[[".mdl"]],
MoreArgs = list(
h = h,
point_forecast = point_forecast,
...,
key_data = key_data(object)
),
SIMPLIFY = FALSE,
future.globals = FALSE
)
}
else{
object[[".fc"]] <- mapply(
FUN = forecast,
object[[".mdl"]],
MoreArgs = list(
h = h,
point_forecast = point_forecast,
...,
key_data = key_data(object)
),
SIMPLIFY = FALSE
)
}
object <- dplyr::mutate_at(as_tibble(object), vars(!!!mdls),
forecast, object[["new_data"]],
h = h, point_forecast = point_forecast, ...,
key_data = key_data(object))

object <- tidyr::pivot_longer(object, !!mdls, names_to = ".model", values_to = ".fc")

# Combine and re-construct fable
fbl_attr <- attributes(object$.fc[[1]])
Expand Down

0 comments on commit f4c96de

Please sign in to comment.