0

我有从 2017 年 7 月到 18 年 7 月的零售数据,并且想将该系列扩展到 17 年 1 月到 17 年 6 月期间,我没有任何数据。

由于这是零售数据,我想使用该prophet软件包,因为它说明了假期和每月/每年的趋势。但是我无法让它预测过去的数据,因为我不能打电话make_future_dataframe给我过去的一段时间。

我无法共享数据,所以在我的示例y中是从rnorm()

data = structure(list(ds = structure(c(17683, 17652, 17622, 17591, 17563, 
17532, 17501, 17471, 17440, 17410, 17379, 17348), class = "Date"), 
y = c(104.668732663406, 98.3902718818212, 109.061616978181, 
109.838504824619, 111.732728009024, 102.108143707743, 99.4680518699638, 
84.228075141372, 110.844516862675, 92.5728013090567, 80.8504745693786, 
108.721168531315)), .Names = c("ds", "y"), row.names = c(NA, 
-12L), class = "data.frame")

m <- prophet(data,seasonality.mode = "multiplicative",yearly.seasonality = T)
future <- make_future_dataframe(m, periods = 6, freq = "1 month")
forecast <- predict(m, future)  %>% data.table() 

有没有一种方法可以让prophet我给我过去的预测而不必填写假日期?

谢谢

4

1 回答 1

0

如果以后有人偶然发现这一点,解决方案是手动创建未来的数据框:

future = data.frame(
  "ds" = as.Date(c(
  "01/01/2017", #No Data
  "02/01/2017", #No Data
  "03/01/2017", #No Data
  "04/01/2017", #No Data
  "05/01/2017", #No Data
  "06/01/2017", #No Data
  "07/01/2017", #Data
  "08/01/2017", #Data
  "09/01/2017", #Data
  "10/01/2017", #Data
  "11/01/2017", #Data    
  "12/01/2017", #Data
  "01/01/2018", #Data
  "02/01/2018", #Data
  "03/01/2018", #Data
  "04/01/2018", #Data
  "05/01/2018", #Data
  "06/01/2018"),
  format = "%m/%d/%Y"
  )
)

predict()将返回所有时期的预测,即使您只提供“未来”的数据。

于 2018-07-30T17:50:55.653 回答