tsseg.algorithms.prophet package

Prophet — trend change point detection via Facebook Prophet.

Description

This detector wraps Facebook Prophet’s piecewise-linear trend model. Prophet specifies a large number of potential change points uniformly placed in the first 80 % of the time series, then applies an L1-regularised (sparse) prior on the rate-change magnitudes so that most potential points go unused. The detector extracts the locations of the significant rate changes from the fitted model.

Key parameters:

  • n_changepoints — number of potential change points.

  • changepoint_prior_scale (tunable inside cost_params) — controls trend flexibility (default 0.05; increase for a more flexible trend).

  • changepoint_range (tunable inside cost_params) — fraction of the history where change points are allowed (default 0.8).

Type: change point detection
Supervision: semi-supervised (n_changepoints recommended)
Scope: univariate (multivariate via ensembling)
Requires: prophet and cmdstanpy

Parameters

Name

Type

Default

Description

n_changepoints

int / None

5

Number of potential change points.

n_changepoint_func

callable / None

None

Callable that determines n_changepoints from the series.

multivariate_strategy

str

"ensembling"

Strategy for multivariate series ("ensembling" or "l2").

tolerance

float

0.01

Tolerance for change-point deduplication.

axis

int

0

Time axis.

Usage

from tsseg.algorithms import ProphetDetector

detector = ProphetDetector(n_changepoints=10)
labels = detector.fit_predict(X)

Implementation: Wrapper around facebook/prophet. MIT.

Reference: Taylor & Letham (2018), Forecasting at Scale, The American Statistician.

Submodules

tsseg.algorithms.prophet.detector module

Prophet-based change-point detector exposed as an aeon segmenter.

class tsseg.algorithms.prophet.detector.ProphetDetector(*, n_changepoints=5, n_changepoint_func=None, axis=0, multivariate_strategy='ensembling', tolerance=0.01)[source]

Bases: BaseSegmenter

Prophet forecaster wrapped as an aeon-compatible change-point detector.

set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') ProphetDetector

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') ProphetDetector

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object

Module contents