Skip to content

feat: allow changepoint_range to be a (start, end) date tuple - #2778

Open
Skpkush wants to merge 1 commit into
meta:mainfrom
Skpkush:feat/changepoint-range-dates
Open

Skpkush wants to merge 1 commit into
meta:mainfrom
Skpkush:feat/changepoint-range-dates

Conversation

@Skpkush

@Skpkush Skpkush commented Nov 6, 2026

Copy link
Copy Markdown

Closes #1987

What

changepoint_range now accepts a (start, end) tuple of dates as well as a proportion. Potential changepoints are placed evenly among the history dates in that window, inclusive. Float behaviour is unchanged.

m = Prophet(changepoint_range=("2012-01-01", "2014-12-31"))

This follows @tcuongd's suggestion on the issue to extend changepoint_range rather than add new __init__ arguments.

Details

  • Dates can be anything pd.Timestamp accepts, and are stored as Timestamps. Bare numbers are rejected, because pd.Timestamp would read them as epoch offsets.
  • model_to_json / model_from_json now handle the tuple, since Timestamps aren't JSON serializable.
  • If the window has fewer dates than n_changepoints, n_changepoints is reduced, as it already is for proportions.
  • If the window contains no history dates, fit raises ValueError.

Questions for review

  1. cross_validation keeps the window fixed, so a cutoff earlier than start raises the ValueError above. I chose an error over silently fitting with no changepoints. Would you prefer a warning?
  2. This is Python only. Should the R package get the same option in a follow-up?

Testing

  • pytest prophet/tests/: 150 passed, 6 skipped, on Windows with Python 3.11 and the CMDSTANPY backend.
  • New tests cover the placement window, a window smaller than n_changepoints, a window outside the history, invalid input and a JSON round trip.
  • I also ran a real fit, predict, JSON round trip and cross_validation with a date window.

Accept a tuple of dates as well as a proportion, placing potential changepoints among the history dates in that window. Serialize the tuple so model_to_json keeps working.
@meta-cla

meta-cla Bot commented Nov 6, 2026

Copy link
Copy Markdown

Hi @Skpkush!

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!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Allow specifying changepoint_ds_lower and changepoint_ds_upper

1 participant