Prophet: Trend that saturates on only one end

Created on 17 Sep 2017  路  17Comments  路  Source: facebook/prophet

The logistic growth trend saturates at both lower and upper bounds. It would be useful to have a trend that saturates only on one end, e.g. that saturates at 0 but does not require specifying an upper bound.

This will require adding a new trend, adding to the linear and logistic growth trends that we already have. I think that the logistic loss function $log(1 + exp(k * (t - m)))$ should work very nicely.

If anyone is interested in making a PR for this we can discuss what is involved.

enhancement help wanted

Most helpful comment

This is a little bit of everything - A new Stan model, and then the interfaces in both Python and R. This should be everything that needs to be done:

  • Determine the formula for the intercepts of a piecewise logistic-loss function. Basically the "k" in the formula will be offset with deltas, and then "m" will be offset with gammas to maintain continuity. This is described for the logistic loss in Section 3.1.1 of the paper and involves doing the algebra to figure out what gamma needs to be for the segment endpoints to line up.
  • Implement a piecewise logistic-loss function that looks like the piecewise logistic function here (In Python and R).
  • Implement an initialization for the logistic loss by computing analytically the values for k and m that produce a curve passing through the first and last points in the dataset, like here for logistic growth. (In Python and R).
  • Implement the piecewise logistic-loss model in Stan, the one for logistic growth here and here.
  • Add it to the list of available models here (Py and R).
  • Unit tests and documentation.

This can be done in parts.

All 17 comments

Hi @bletham, I am interested in taking a shot at this, is it a Python or R fix?

This is a little bit of everything - A new Stan model, and then the interfaces in both Python and R. This should be everything that needs to be done:

  • Determine the formula for the intercepts of a piecewise logistic-loss function. Basically the "k" in the formula will be offset with deltas, and then "m" will be offset with gammas to maintain continuity. This is described for the logistic loss in Section 3.1.1 of the paper and involves doing the algebra to figure out what gamma needs to be for the segment endpoints to line up.
  • Implement a piecewise logistic-loss function that looks like the piecewise logistic function here (In Python and R).
  • Implement an initialization for the logistic loss by computing analytically the values for k and m that produce a curve passing through the first and last points in the dataset, like here for logistic growth. (In Python and R).
  • Implement the piecewise logistic-loss model in Stan, the one for logistic growth here and here.
  • Add it to the list of available models here (Py and R).
  • Unit tests and documentation.

This can be done in parts.

Hey all, do we have any update on this?

Let's hold off on this until after #501, which will make it much easier and require much less code duplication.

What happened on this? #501 doesn't seem to be done yet many months later. So #307 hasn't been started? What is the recommended solution to this problem currently?

@BernierCR the latest Stan a few months ago (2.18) did add a standalone generated quantities functionality that we were planning to use for #501, but it has not yet been piped into rstan or pystan. That piping seems to be going slowly so we are right now looking into handling #501 without waiting for standalone generated quantities. We had tried this last summer and ran into some upstream bugs, hopefully it is successful this time.

In the meantime, you can get that behavior by using the logistic trend but setting the bound on the side that you don't want a bound to just be a a larger number than your forecast ever reaches.

@bletham I noticed that the forecast changes based on the upper bond, it seems to scale inversely, the higher the upper bond the smaller the forecast, is this the supposed behaviour?

Could you post the plot so I can see what you mean?

Any update on when this will be available?

865 is the PR that moves predictions to Stan. There are still some issues there but we're working through them, and once they're resolved this would be next.

Ok, sounds good, thanks! :)

Setting the upper bound to a very high relative value will work though, right?

hello! just that check the current progress of prophet's feature of not need an upper bound for saturating floor. I currently face the issue of needing to only bound my forecast to 0 yet do not want to enforce an upper bound.

not sure if setting an upper bound will actually alter the intended forecast (even if we set an arbitrary high bound)

No progress, ran into some difficulty in #865 and trying to figure out a good workaround on the rstan side.

Does anybody have an alternative solution for this meanwhile? because #307 not moving forward.

I was targeting for this to happen after #501, which would have made it easier / more generic, but after the addition of the cmdstanpy backend I've decided to no longer pursue #501 so this should just be done directly.

The new trend function can be added in the same way that the linear and logistic trends are. This is basically what needs to be done, in R and Py:

How does inputing an arbitrary large value on cap would affect the results?

I think one of the main applications of this is data that has to be positive but isn't necessarily saturating at an upper limit. There's discussion of that setting in #1668 along with some strategies so I just wanted to point people to that issue in case anyone wants to try the approaches described there. I'm especially interested to hear if the ProphetPos class that is described in that issue provides a satisfactory solution to the use cases here.

Was this page helpful?
0 / 5 - 0 ratings