Error creating prophet object - Error in filter_imp(.data, quo)
See original GitHub issueI am trying to create a prophet object of my data frame by passing grouped data using the following code. Essentially, I would like my predictions at group level, therefore I subset the data frame and create prophet object for predict and then merge all groups together. However, I am not certain about the error I am receiving which seems to be from dplyr which is used by prophet library.
modelGroup <- function(x) { cdpModel <- prophet(x, changepoint.prior.scale = 0.5) cdpFuture <- make_future_dataframe(cdpModel, periods = 52, freq = "week) forecast <- predict(cdpModel, cdpFuture) return ......
Here some sample data
Week Group Count 16-01-01 A 10 17-01-01 B 15 15-01-01 C 20
I can’t seem to figure out the error, my function call subsets the data by group and passes a date and count column data frame to the function.
results <- DataTable[, lapply(.SD, modelGroup), by = DISTRICT]
Traceback:
`Error in filter_impl(.data, quo) : Result must have length 22923 not 9 17. call = filter_imp(.data, quo), cppstack = structure(list(file = “” line -1L, stack = c("usr/lib64/R/library/dplyr.so(Rcpp::exception::exception(char const*, bool)+0x73), "/usr/lib64/R/library/dplyr/libs/dplyr.so(void Rcpp::stop<int, long>(char const*, int const&, long const&)+0x55) 16. filter_imp(.data, quo) 15. filter.tbl_df(d=tvk_df(.data), …) . . . 11. dplyr::filter(., !is.na(y)) . . . 3. df %>% dplyr::filter(!is.na(y)) 2. fit.prophet(m, df, …)
- prophet(df = dataframe)`
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
This isn’t an issue anymore. The columns had to be renamed to
ds
andy
before passing them to the function to create prophet object and running the model. Thanks for your time.Interesting @bletham. I verified that the dataset
(x)
being passed to the function always has 2 columns, weekly time stamp(ds)
andy
. Before the function call, the data frame is being subset with each group and only the selected 2 cols are passed to the functionmodelGroup
.