The seasonality component in the forecast for the training data differs from that in the future predictions · Issue #2662 · facebook/prophet · GitHub
Skip to content

The seasonality component in the forecast for the training data differs from that in the future predictions #2662

Open

Description

@CHELODOR3000

Hi!

I have encountered an issue while using Facebook Prophet for time series forecasting. The seasonal component included in the forecast for the training data appears to be different from the seasonal component applied when making future predictions. Specifically, the weekly seasonality pattern observed in historical data does not seem to be reflected consistently in the forecasted values for the future.

Ultimately, due to this issue, the forecast for the future appears unrealistic in terms of weekly seasonality. I have not been able to find an explanation for this behavior myself. I would greatly appreciate any explanation from knowledgeable professionals.

Below, I have included a code snippet and a visualization to illustrate the issue. Thank you!

def single_prophet(df, train_dates, seasonality_mode='additive'):
    df = df.copy()
    df['ds'] = pd.to_datetime(df['ds']) 
    df = df.sort_values('ds')
    future_pred_dates = pd.DataFrame(pd.date_range(start=pd.Timestamp.now(), end=pd.Timestamp('2025-12-31'), freq='D'), columns=['ds'])

    model = Prophet(seasonality_mode=seasonality_mode) # , holidays=holidays, holidays_prior_scale=1
    model.fit(df[df['ds'] >= train_dates[0]])
    fact_pred = model.predict(df[df['ds'] >= train_dates[0]][['ds']])
    future_pred = model.predict(future_pred_dates)


    fig = go.Figure()

    fig.add_trace(go.Scatter(x=df.ds, y=df['y'], name='fact'))
    fig.add_trace(go.Scatter(x=fact_pred.ds, y=fact_pred['yhat'], name='fact_pred'))
    fig.add_trace(go.Scatter(x=fact_pred.ds, y=fact_pred['trend'], name='fact_trend'))
    fig.add_trace(go.Scatter(x=fact_pred.ds, y=fact_pred['weekly'], name='fact_weekly'))
    
    fig.add_trace(go.Scatter(x=future_pred.ds, y=future_pred['yhat'], name='future_pred'))
    fig.add_trace(go.Scatter(x=future_pred.ds, y=future_pred['trend'], name='future_trend'))
    fig.add_trace(go.Scatter(x=future_pred.ds, y=future_pred['weekly'], name='future_weekly'))
    
    fig.show()

single_prophet(
    data, 
    train_dates=['2025-02-01', '2025-03-01']
)
Image Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions