Error running fable prophet -- MacOs Issue?--

Guys, trying to run some prophet models here and I got the following issues:
50 errors (1 unique) encountered for p1
[50] c++ exception (unknown reason)
50 errors (1 unique) encountered for p2
[50] c++ exception (unknown reason)
50 errors (1 unique) encountered for p3
[50] c++ exception (unknown reason)
Any guess, what could be?

library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.6.2
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tsibble)
#> Warning: package 'tsibble' was built under R version 3.6.2
library(fable)
#> Warning: package 'fable' was built under R version 3.6.2
#> Carregando pacotes exigidos: fabletools
library(fable.prophet)
#> Warning: package 'fable.prophet' was built under R version 3.6.2
#> Carregando pacotes exigidos: Rcpp
#> Warning: package 'Rcpp' was built under R version 3.6.2


iniciativa <- tibble(
    data_planejada = seq(as.Date("2020-01-01"), length = 200, by = "1 day"),
    n = sample(seq(100), size = 200, replace = TRUE)
) %>%
    as_tsibble(index = data_planejada)

iniciativa_cv <- iniciativa %>%
    stretch_tsibble(.init=20, .step=1)


prophet_tbl <- iniciativa_cv %>% 
    model(
        p1 = prophet(n ~ season(period = "week", order = 3, type = "multiplicative")),
        p2 = prophet(n ~ season(period = "week", order = 3, type = "additive")), 
        p3 = prophet(n ~ season(period = "week", order = 3))
    )
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 16
#> n.changepoints greater than number of observations. Using 17
#> n.changepoints greater than number of observations. Using 18
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 20
#> n.changepoints greater than number of observations. Using 21
#> n.changepoints greater than number of observations. Using 22
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 24
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 16
#> n.changepoints greater than number of observations. Using 17
#> n.changepoints greater than number of observations. Using 18
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 20
#> n.changepoints greater than number of observations. Using 21
#> n.changepoints greater than number of observations. Using 22
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 24
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 15
#> n.changepoints greater than number of observations. Using 16
#> n.changepoints greater than number of observations. Using 17
#> n.changepoints greater than number of observations. Using 18
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 19
#> n.changepoints greater than number of observations. Using 20
#> n.changepoints greater than number of observations. Using 21
#> n.changepoints greater than number of observations. Using 22
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 23
#> n.changepoints greater than number of observations. Using 24
#> Warning: 80 errors (1 unique) encountered for p1
#> [80] c++ exception (unknown reason)
#> Warning: 80 errors (1 unique) encountered for p2
#> [80] c++ exception (unknown reason)
#> Warning: 80 errors (1 unique) encountered for p3
#> [80] c++ exception (unknown reason)

fc_tbl <- prophet_tbl %>%
    forecast(h=5) %>%
    group_by(.id) %>%
    mutate(h = row_number()) %>%
    ungroup()

fc_tbl %>% accuracy(
    iniciativa, 
    by=c("h",".model"),
    list(rmse = RMSE, mae = MAE, mape = MAPE, mase = MASE, crps = CRPS, winkler = winkler_score)
)
#> Warning: The future dataset is incomplete, incomplete out-of-sample data will be treated as missing. 
#> 5 observations are missing between 2020-07-19 and 2020-07-23
#> # A tibble: 15 x 9
#>        h .model .type  rmse   mae  mape  mase  crps winkler
#>    <int> <chr>  <chr> <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>
#>  1     1 p1     Test   30.7  25.8  238. 0.800  17.8    127.
#>  2     2 p1     Test   31.2  25.9  244. 0.803  18.1    137.
#>  3     3 p1     Test   31.0  26.0  242. 0.807  18.0    132.
#>  4     4 p1     Test   31.2  25.9  244. 0.806  18.1    139.
#>  5     5 p1     Test   30.8  25.6  245. 0.796  17.8    132.
#>  6     6 p2     Test   30.6  25.7  239. 0.798  17.8    133.
#>  7     7 p2     Test   30.8  25.7  243. 0.799  17.9    135.
#>  8     8 p2     Test   31.0  26.0  246. 0.808  18.1    132.
#>  9     9 p2     Test   30.7  25.7  247. 0.797  17.8    133.
#> 10    10 p2     Test   30.7  25.5  245. 0.794  17.8    132.
#> 11    11 p3     Test   30.4  25.6  239. 0.795  17.7    130.
#> 12    12 p3     Test   30.9  25.9  242. 0.803  18.0    135.
#> 13    13 p3     Test   30.9  25.9  246. 0.805  18.0    133.
#> 14    14 p3     Test   30.8  25.7  247. 0.798  17.9    135.
#> 15    15 p3     Test   30.6  25.3  245. 0.787  17.7    130.

Created on 2020-12-28 by the reprex package (v0.3.0)

Are you able to run the examples from the {prophet} package?
This is likely an issue with your rstan/prophet installation, as {fable.prophet} provides a simple wrapper around these packages allowing it to be used with a {fable} interface.

1 Like

I was not, difficult to know how to fix it because for me the error message do not say me nothing:
Warning: 80 errors (1 unique) encountered for p1
[80] c++ exception (unknown reason)

fable.prophet has worked fine for me with both R 3.6.3 on MacOS 10.14 (Catalina) and R 4.0.3 on MacOS 11.1 (Big Sur). I recall a problem with Prophet involving rstan and/or Rcpp, but not exactly what the solution was. I did install Rcpp 1.0.5.2, but that may have been for another issue. Sorry I cannot be more helpful.

I couple of suggestions on your code. First, I would not start the cross validation with just 20 observations. My rule of thumb for fitting seasonal models is at least five complete repeats of the seasonal pattern, which would be five weeks of daily observations = 35. This would also avoid the problem that appears with your n.changepoints warnings. The default is set to 25, which is impossible with just 20 observations. You can also set n_changepoints to a lower number in the growth() special in the prophet() function. I changed it 12 to run your code.

Second, if you are going to use h = 5 then drop the last five observations from iniciativa when you do stretch_tsibble(). If you stop at 195 then you can forecast ahead 5 days and then compare that to known data. If you go all the way to 200 and then forecast ahead 5 days, there is nothing to compare to, hence the "future dataset is incomplete" warning.

1 Like

Thanks for provided some suggestions for my code, I just adjusted "iniciativa"to drop the last five observations, I was a little confuse about this point, you elucidate me with your explanation.
One thing I had notice, that for my first observations of my cross validation the prophet model return null values, not really sure why.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.