Prophet: Prophet crashes R

Created on 23 Mar 2017  路  10Comments  路  Source: facebook/prophet

I've been experimenting with Prophet and I am finding it unusable because it keeps on crashing R -- from within RStudio I get "R Session Aborted. R Encountered a fatal error. The session was terminated." This is within code that is evaluating Prophet by running it multiple times with a sliding window of data and seeing how good its predictions are. The point at which it crashes varies from run to run -- I may do five calls to Prophet, or nearly hundred, before it crashes -- but it always does crash before I finish the sequence.

Also, Prophet doesn't work unless you do "library(rstan)" before using it.

bug

Most helpful comment

I ran into the same Rcpp problems as originally described by @ksvanhorn earlier today. After installing the latest github version, I still get errors:

ds <- seq(as.Date('2005-04-01'), as.Date('2005-09-03'), by='day')
x <- (1:length(ds))/length(ds)
y <- rnorm(length(ds), x * (1 - x) + 0.5, 0.1)
prophet::prophet(data.frame(ds = ds, y = y), yearly.seasonality = FALSE)
Error in .Object$initialize(...) :
could not find function "cpp_object_initializer"
failed to create the optimizer; optimization not done
Error in matrix(m$params[[name]], nrow = n.iteration) :
'data' must be of a vector type, was 'NULL'

@bletham, should I re-open a separate issue?

All 10 comments

This may be relevant:

https://github.com/stan-dev/rstan/issues/388

I am running on a Mac, same as the person who reported that issue.

This may be the same as #93, but @ksvanhorn I am not able to replicate your issue with Prophet not working without using library(rstan). Can you give some more details about what error you are getting if you use Prophet without separately loading rstan?

To reproduce the problem with not working unless you do library(rstan) first:

  1. Start with a fresh R session, nothing loaded.

  2. Execute the following code:
    ds <- seq(as.Date('2005-04-01'), as.Date('2005-09-03'), by='day')
    x <- (1:length(ds))/length(ds)
    y <- rnorm(length(ds), x * (1 - x) + 0.5, 0.1)
    prophet::prophet(data.frame(ds = ds, y = y))

Here's the error I get:

Error in .Object$initialize(...) :
could not find function "cpp_object_initializer"
failed to create the optimizer; optimization not done
Error in matrix(m$params[[name]], nrow = n.iteration) :
'data' must be of a vector type, was 'NULL'

The problem doesn't occur if I load prophet first (with library(prophet)), but only if I try to use it as shown. The use case for not doing "library(prophet)" first is when you're putting together a package to be used within your team -- package source files should never do library() calls.

NOTE: The issue with R crashing is an entirely separate issue that only happens when I'm calling prophet repeatedly from within a loop.

Thanks for the clear repro! It's actually Rcpp that has to be loaded before it will work. It looks like there has been some discussion of this upstream with rstan and other packages that use it, so we'll have to figure out what can be done here.

As for the crashes when run in a loop, I have reproduced this from the discussion in #93. I think the stan fitting is on rare occasions failing but hopefully we can catch it before it segfaults.

This should be fixed in #93, please install the latest version from Github and see if you run into any further issues here:

devtools::install_github('facebookincubator/prophet', subdir='R')

I ran into the same Rcpp problems as originally described by @ksvanhorn earlier today. After installing the latest github version, I still get errors:

ds <- seq(as.Date('2005-04-01'), as.Date('2005-09-03'), by='day')
x <- (1:length(ds))/length(ds)
y <- rnorm(length(ds), x * (1 - x) + 0.5, 0.1)
prophet::prophet(data.frame(ds = ds, y = y), yearly.seasonality = FALSE)
Error in .Object$initialize(...) :
could not find function "cpp_object_initializer"
failed to create the optimizer; optimization not done
Error in matrix(m$params[[name]], nrow = n.iteration) :
'data' must be of a vector type, was 'NULL'

@bletham, should I re-open a separate issue?

@z1lc Yes, if you could open a separate issue for this that'd be great (to separate this issue of not being usable without library(prophet) from the fixed issue of crashing if run in a loop).

285

Was this page helpful?
0 / 5 - 0 ratings