Skip to content

feat(prophet): add FoundationProphet adapter - #87

Merged
AzulGarza merged 18 commits into
mainfrom
feat/prophet-adapter
Nov 6, 2026
Merged

AzulGarza merged 18 commits into
mainfrom
feat/prophet-adapter

Conversation

@AzulGarza

Copy link
Copy Markdown
Member

Summary

Adds foundationforecast.prophet.FoundationProphet, a prophet.Prophet subclass that runs any foundation model instead of the Stan model, so existing Prophet pipelines can swap models in one line:

from foundationforecast.models import Chronos
from foundationforecast.prophet import FoundationProphet

m = FoundationProphet(model=Chronos())  # instead of Prophet()
m.fit(df)                               # ds, y (+ regressors)
future = m.make_future_dataframe(periods=30)
forecast = m.predict(future)            # ds, yhat, yhat_lower, yhat_upper
  • fit stores the history (zero-shot models need no training); predict calls model.forecast with level=[interval_width * 100] and maps the output to yhat, yhat_lower, yhat_upper.
  • Historical rows (make_future_dataframe(include_history=True)) are filled with rolling-origin backtests from model.cross_validation (insample="cv", default) and a message is logged explaining the cost and how to skip it. insample="none" leaves them NaN. insample_h / insample_n_windows tune the windows.
  • add_regressor columns are passed as known-future exog (X_df), so they work with models that support native exog.
  • Prophet's diagnostics.cross_validation / performance_metrics, plot, make_future_dataframe, deepcopy and pickle work. plot_components and posterior sampling raise NotImplementedError.
  • Takes any single Forecaster; it never inspects the concrete model, so a future ensemble forecaster can be passed as model=.
  • prophet is an optional extra (foundationforecast[prophet]) and is also in the dev group so CI runs the tests. foundationforecast.prophet is not imported by the package __init__.

Docs

  • New guide docs/prophet-adapter.md, API page docs/api/prophet.md, example notebook docs/examples/prophet-adapter.ipynb, plus README, installation and examples index entries.

Test plan

  • uv run pytest tests/test_prophet_adapter.py (34 unit tests with a fake Forecaster + 2 models tests with Chronos-Bolt and Chronos-2 regressors)
  • uv run pytest -m docs -o addopts= -n 0 tests/docs/test_docs.py -k prophet
  • uv run --group docs zensical build
  • uv run pre-commit run --all-files

Made with Cursor

Copilot AI balanced review requested due to automatic review settings November 4, 2026 18:23
@codspeed

codspeed Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 note

ℹ️ 13 benchmarks have no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

✅ 17 untouched benchmarks


Comparing feat/prophet-adapter (bde7c02) with main (5c91f35)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues can distort historical time spacing, cause conformal backtests and Prophet diagnostics to fail, and produce intervals inconsistent with the current interval width.

4 open issues
What changed in this PR

Adds FoundationProphet, a Prophet-compatible adapter that connects existing Prophet pipelines to FoundationForecast models.

Changes:

  • Implements forecasting, prediction intervals, historical backtests, and known-future regressors through the Forecaster interface.
  • Adds adapter tests, including Chronos integration and Prophet compatibility checks.
  • Introduces an optional Prophet dependency, documentation, and an example notebook.
File Description
uv.lock Locks Prophet and its dependencies.
tests/​test_prophet_adapter.py Tests adapter behavior and model integrations.
README.md Highlights the adapter and installation extra.
pyproject.toml Adds Prophet as an optional and development dependency.
mkdocs.yml Registers adapter documentation and examples.
foundationforecast/​prophet.py Implements the Prophet-compatible adapter.
docs/​prophet-adapter.md Explains usage, regressors, backtests, and limitations.
docs/​getting-started/​installation.md Documents the Prophet installation extra.
docs/​examples/​prophet-adapter.ipynb Demonstrates forecasting and diagnostic comparisons.
docs/​examples/​index.md Lists the adapter notebook.
docs/​api/​prophet.md Adds the adapter API reference.

Review effort: Balanced

Comment thread foundationforecast/prophet.py Resolved
Comment thread foundationforecast/prophet.py Resolved
Comment thread foundationforecast/prophet.py Resolved
Comment thread foundationforecast/prophet.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Integer dates are misparsed as 1970 timestamps and silently yield NaN predictions, while numeric-string targets break diagnostics and adapter clones can evaluate the wrong model.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Rebind adapter class when constructed with a different model

foundationforecast/​prophet.py:185

When a bound adapter is reconstructed with a different explicit model, such as other = type(m)(model=another_model), this guard leaves its class bound to the original model. Subsequent Prophet-style clones (type(other)(...)) silently revert to that original model, so diagnostics evaluate a different model from other.model. Rebind whenever the bound model differs from the requested model, using the unbound base class.

Medium severity Convert retained target values to numeric before storing history

foundationforecast/​prophet.py:229

Numeric strings in y remain strings in the stored history, so Prophet's performance_metrics(cross_validation(m, ...)) fails when it computes errors against those actuals. Convert retained targets with pd.to_numeric before storing the history, matching Prophet's input handling.

4 resolved since last review

Review effort: Balanced

Comment thread foundationforecast/prophet.py Resolved
Comment thread docs/prophet-adapter.md Resolved
Comment thread docs/prophet-adapter.md Resolved
Comment thread docs/prophet-adapter.md Resolved
Comment thread README.md Resolved
Comment thread foundationforecast/prophet.py Resolved
Comment thread foundationforecast/prophet.py Resolved
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.27273% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
foundationforecast/prophet.py 97.27% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@AzulGarza
AzulGarza merged commit 6affe14 into main Nov 6, 2026
14 checks passed
@AzulGarza AzulGarza mentioned this pull request Nov 9, 2026
@AzulGarza
AzulGarza deleted the feat/prophet-adapter branch November 9, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants