[Python] Prophet forecast data doesn't match observed data

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    Context


    I'm trying to model office attendance using the Prophet library in python. My data is pretty simple, headcounts at 15 minute intervals. It's shown by the black dots in the plot below.

    [​IMG]

    The daily and weekly trends look spot on:

    [​IMG]

    I've also included holidays.

    The code looks like this:

    m = Prophet(holidays=holidays, weekly_seasonality=True, growth="flat") # "logistic")
    p_df = sdf[["OCCUPANCY_AVG"]].reset_index()
    p_df.columns = ["ds", "y"]
    p_df["cap"] = 180
    df["floor"] = 0
    m.fit(p_df)

    future = m.make_future_dataframe(periods=24 * 60, freq="H")
    future["cap"] = 180
    future["floor"] = 0
    # future.tail()

    forecast = m.predict(future)
    # forecast[["ds", "yhat", "yhat_lower", "yhat_upper"]].tail()

    fig1 = m.plot(forecast, xlabel="Date", ylabel="Headcount", include_legend=True)
    # %%
    fig2 = m.plot_components(forecast)

    Question


    There are several things that I'm not thrilled about here:

    • The forecast data can't, in real life, go negative
    • The observed data peaks are much higher than even the uncertainty interval

    How can I make the model respect that it's predicting a quantity that can't go negative, and also make it fit the input data?

    Continue reading...

Compartilhe esta Página