Skip to content

fix: plot seasonalities of logistic models with minmax scaling and no floor - #2772

Open
RaphaelFakhri wants to merge 1 commit into
meta:mainfrom
RaphaelFakhri:fix/seasonality-plot-minmax-floor
Open

RaphaelFakhri wants to merge 1 commit into
meta:mainfrom
RaphaelFakhri:fix/seasonality-plot-minmax-floor

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

A logistic model fit with scaling='minmax' and no floor column has its floor set to min(y). seasonality_plot_df always used cap=1, so setup_dataframe raised ValueError: cap must be greater than floor whenever min(y) >= 1. That broke plot_components, plot_weekly, plot_yearly, plot_seasonality, and their plotly versions for these models.

df = pd.DataFrame({
    "ds": pd.date_range("2020-01-01", periods=800),
    "y": 100 + 10 * np.sin(np.arange(800) / 7.0),
})
df["cap"] = 200.0
m = Prophet(growth="logistic", scaling="minmax").fit(df)
m.plot_components(m.predict(m.make_future_dataframe(10).assign(cap=200.0)))
# ValueError: cap must be greater than floor (which defaults to 0).

Changes

  • seasonality_plot_df uses y_min as the floor when setup_dataframe will use it (minmax scaling, no logistic floor), and sets cap one unit above the floor. Seasonal components don't depend on cap, so the plotted values don't change for any other model.
  • Adds test_logistic_minmax_without_floor, which checks that the seasonality plot data matches the weekly component returned by predict.

Testing

python -m pytest prophet/tests/test_plot.py -k logistic_minmax
  • Without the fix: 1 failed (ValueError: cap must be greater than floor).
  • With the fix: 1 passed. prophet/tests has 143 passed and 2 skipped. pyrefly check reports the same results before and after the change.

Fixes #2771

@meta-cla

meta-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Hi @RaphaelFakhri!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Oct 27, 2026
@meta-cla

meta-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plot_components fails for logistic models with minmax scaling and no floor

1 participant