tsseg.algorithms.beast package
BEAST (Bayesian Estimator of Abrupt change, Seasonality, and Trend).
Description
BEAST decomposes a time series into trend + seasonality + noise via Bayesian model averaging (BMA) over a large space of piecewise-linear trend models and piecewise-harmonic seasonal models. Change points are inferred from the posterior distribution using Reverse-Jump MCMC (RJ-MCMC) and Gibbs sampling. Each time step receives a posterior probability of being a change point.
Instead of selecting a single “best” segmentation, BEAST integrates over all candidate models weighted by their posterior probability, yielding robust detection with uncertainty quantification.
Three strategies handle multivariate inputs:
"native"— usesbeast123which handles multi-dimensional data natively."l2"— reduces channels via L2 norm before inference."ensembling"— runs BEAST per channel and aggregates change points.
max_cps)Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Seasonal model type: |
|
tuple |
|
(min, max) number of trend change points. |
|
tuple |
|
(min, max) polynomial orders for the trend. |
|
int / None |
|
Minimum segment length for the trend component. |
|
tuple |
|
(min, max) number of seasonal change points. |
|
tuple |
|
(min, max) harmonic orders for the seasonal component. |
|
int / None |
|
Minimum segment length for the seasonal component. |
|
float |
|
Period of the seasonal signal (e.g. 12 for monthly/annual). |
|
float |
|
Time interval between consecutive observations. |
|
int |
|
Number of MCMC samples to collect. |
|
int |
|
Number of initial samples to discard per chain. |
|
int |
|
Number of MCMC chains to run. |
|
int |
|
Thinning factor for the MCMC chains. |
|
int |
|
Random seed (0 = no fixed seed). |
|
float |
|
Minimum posterior probability to accept a change point. |
|
int / None |
|
Optional upper bound on the number of change points. |
|
str |
|
Which component’s change points to return: |
|
str |
|
|
|
float |
|
Tolerance for aggregating change points in ensembling mode. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import BeastDetector
# Trend-only detection (no seasonality)
detector = BeastDetector(season="none", cp_prob_threshold=0.2)
labels = detector.fit_predict(X)
# Seasonal data (e.g. monthly with annual period)
detector = BeastDetector(season="harmonic", period=12)
labels = detector.fit_predict(X)
Implementation: Wraps the Rbeast C library, vendorized in c/Rbeast/
(patched for numpy >= 2.0). Build with make in c/Rbeast/.
Reference: Zhao et al. (2019), Detecting change-point, trend, and seasonality in satellite time series data, Remote Sensing of Environment.