Prophet: 'predict' without uncertainty estimation

Created on 6 May 2019  路  2Comments  路  Source: facebook/prophet

Would it be possible to speed up 'predict' by having an option to only return yhat and not uncertainties and estimators? I'm using it in a separate Monte Carlo step where I think there would be a major speedup by only returning this quantity (even if samples is set to 1)

Most helpful comment

Fantastic - thanks for the help. I also updated the component _for loop_ in predict_seasonal_components to only calculate additive and/or multiplicative terms resulting in a 90%+ speedup in cases where only yhat is necessary.

# for (component in colnames(component.cols)) {
  for (component in c("additive_terms", "multiplicative_terms")) {

All 2 comments

That makes sense, we'll have to figure out if this is a broad enough use case to justify an extra interface but I think it could be reasonable to add a kwarg to predict that disables uncertainty estimation.

In the meantime, there isn't actually a whole lot of code in the predict method (https://github.com/facebook/prophet/blob/master/python/fbprophet/forecaster.py#L1139) and this can be pretty easily done just by making a custom predict function:

def predict_no_uncertainty(m, df):
    df = m.setup_dataframe(df.copy())
    df['trend'] = m.predict_trend(df)
    seasonal_components = m.predict_seasonal_components(df)

    df2 = pd.concat((df[['ds', 'trend']], seasonal_components), axis=1)
    df2['yhat'] = (
            df2['trend'] * (1 + df2['multiplicative_terms'])
            + df2['additive_terms']
    )
    return df2

Fantastic - thanks for the help. I also updated the component _for loop_ in predict_seasonal_components to only calculate additive and/or multiplicative terms resulting in a 90%+ speedup in cases where only yhat is necessary.

# for (component in colnames(component.cols)) {
  for (component in c("additive_terms", "multiplicative_terms")) {
Was this page helpful?
0 / 5 - 0 ratings