Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/prophet/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ def seasonality_plot_df(
-------
A dataframe with seasonal components on ds.
"""
df_dict = {'ds': ds, 'cap': 1., 'floor': 0.}
cap = 1.0
if m.scaling == "minmax" and not m.logistic_floor and m.y_min is not None:
cap = float(m.y_min) + 1.0
df_dict = {'ds': ds, 'cap': cap, 'floor': 0.}
for name in m.extra_regressors:
df_dict[name] = 0.
# Activate all conditional seasonality columns
Expand Down
14 changes: 14 additions & 0 deletions python/prophet/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,17 @@ def test_plotly_draws_data(self, model_and_forecast):
traces = get_seasonality_plotly_props(m, "weekly")["traces"]
np.testing.assert_array_equal(pd.to_datetime(traces[0].x), data["ds"])
np.testing.assert_array_equal(traces[0].y, data["weekly"])

def test_seasonality_plot_df_logistic_minmax_without_floor(self):
m = Prophet(growth="logistic", scaling="minmax")
df = pd.DataFrame({
"ds": pd.date_range("2020-01-01", periods=20),
"y": np.linspace(100.0, 150.0, 20),
"cap": 200.0,
})
m.fit(df)
days = pd.date_range("2020-01-01", periods=7)
plot_df = seasonality_plot_df(m, days)
assert len(plot_df) == 7
assert (plot_df["cap"] > plot_df["floor"]).all()