diff --git a/python/prophet/diagnostics.py b/python/prophet/diagnostics.py index 89f740c06..8848b12f7 100644 --- a/python/prophet/diagnostics.py +++ b/python/prophet/diagnostics.py @@ -399,6 +399,7 @@ def prophet_copy(m: _ModelT, cutoff: pd.Timestamp | None = None) -> _ModelT: m2.extra_regressors = deepcopy(m.extra_regressors) m2.seasonalities = deepcopy(m.seasonalities) m2.country_holidays = deepcopy(m.country_holidays) + m2.fit_kwargs = deepcopy(m.fit_kwargs) return m2 diff --git a/python/prophet/tests/test_diagnostics.py b/python/prophet/tests/test_diagnostics.py index f8bd7b507..2c7294664 100644 --- a/python/prophet/tests/test_diagnostics.py +++ b/python/prophet/tests/test_diagnostics.py @@ -593,6 +593,15 @@ def test_prophet_copy_scaling(self, data, backend): m2 = diagnostics.prophet_copy(m1) assert m2.scaling == "minmax" + def test_prophet_copy_fit_kwargs(self, data, backend): + m1 = Prophet(stan_backend=backend) + m1.history = m1.setup_dataframe(data.copy(), initialize_scales=True) + m1.fit_kwargs = {"iter": 500, "algorithm": "Newton"} + m2 = diagnostics.prophet_copy(m1) + assert m2.fit_kwargs == {"iter": 500, "algorithm": "Newton"} + m2.fit_kwargs["iter"] = 1000 + assert m1.fit_kwargs["iter"] == 500 + def test_prophet_copy_custom(self, data, backend): changepoints = pd.date_range("2012-06-15", "2012-09-15") cutoff = pd.Timestamp("2012-07-25")