AI Glossary / Statistics and probability / Intermediate
Time-series segmentation
Definition
Time-series segmentation divides an ordered sequence into contiguous intervals that are relatively coherent under a chosen criterion. The boundaries may reflect changes in mean, variance, trend, dependence, or another modeled feature. It is often used to summarize behavior, detect regimes, or prepare data for further analysis while preserving temporal order.
What it means
A long sequence may contain several distinct phases rather than one stable process. Segmentation seeks boundaries between those phases so that each part can be described more simply or consistently.
What counts as a coherent segment depends on the task. A method targeting changes in average level may miss changes in variability or frequency content. The returned boundaries are therefore results of a model and objective, not automatically objectively correct event times or causal explanations.
How it works
Define the purpose of segmentation. It may support retrospective description, online monitoring, compression, classification, or forecasting. A method that can inspect the entire recorded series has different information from one that must make decisions as observations arrive.
Choose the features and within-segment model. A piecewise-constant mean model summarizes each segment by its average. Other models can represent linear trends, changing covariance, or distributional differences. Match the model to the type of change that matters.
Specify a cost for fitting each segment. For a mean-change model, a common cost is the sum of squared deviations from the segment mean. Lower total fitting cost indicates a better fit to the observed values under that criterion.
Control complexity. Allowing every observation to form its own segment can make fitting error vanish without producing a useful explanation. A fixed number of boundaries, a penalty per boundary, or a minimum segment length constrains the solution.
Select a search algorithm. Dynamic programming can optimize certain objectives exactly, while methods such as binary segmentation or sliding-window searches make different computational trade-offs. PELT uses pruning to accelerate penalized segmentation under its conditions.
Preserve the time structure and relevant preprocessing information. Irregular spacing, missing observations, seasonal patterns, and correlated errors can affect the interpretation of costs and boundaries. Removing seasonality may be justified for one question and erase useful structure for another.
Validate the chosen settings. Excessively weak penalties produce many small segments; excessively strong penalties can hide meaningful changes. Use domain evidence, simulation, appropriate validation data, and sensitivity analysis rather than choosing parameters solely for an attractive chart.
Distinguish boundary detection from explanation. A change in the measured series could reflect a real regime shift, a sensor recalibration, a revised definition, or a data-processing issue. Examine metadata and context before attaching an operational label.
For predictive use, avoid using future observations to construct features that would not have been available at prediction time. Offline segmentation can be valuable for historical analysis while being unsuitable as a direct simulation of live detection performance.
Three practical examples
- Operations monitoring: identify periods with different average processing times.
- Sensor analysis: summarize a recording into regimes with distinct signal behavior.
- AI workflow analysis: locate changes in model performance while checking whether evaluation data or labeling rules changed.
Think of it this way
Think of dividing a recorded journey into stretches of similar travel behavior, such as steady movement and stop-start traffic. The boundaries depend on whether you care about speed, variability, or route changes. A useful division for one purpose may not be the best division for another.
Worked example
Consider an original six-point series: 1, 1, 2, 8, 9, 9. Use a piecewise-constant mean model with squared-error cost. With no boundary, the mean is 5 and the cost is 16 + 16 + 9 + 9 + 16 + 16 = 82.
Place a boundary after the third observation. The first segment has mean 4/3 and squared-error cost 2/3. The second has mean 26/3 and the same cost, 2/3. Total fitting cost is therefore 4/3, approximately 1.333. Checking all five possible single boundaries confirms that this is the lowest single-boundary cost.
If the objective adds a penalty of 10 for each boundary, the two-segment objective is 4/3 + 10, approximately 11.333, compared with 82 for no boundary. Under a rule allowing at most one boundary, the split is preferred.
With a penalty of 100, its objective becomes approximately 101.333, so no boundary is preferred. The example shows how the penalty changes the selected complexity; it does not prove that a real-world event occurred between observations three and four.
Illustrative case study
Fictional case: Elm Monitoring segments a history of AI service latency and finds a sharp change. Engineers initially suspect a new model version, but the timestamp aligns with a logging change that began including queue time. They label the measurement break and reassess the series on a comparable definition. They also compare several reasonable penalties to see whether other boundaries persist. Segmentation helps focus investigation without determining the cause by itself.
Common misconceptions and mistakes
Do not confuse contiguous segmentation with clustering observations regardless of order. A lower fitting error alone does not justify more segments. A detected boundary is not necessarily a causal event. Offline results can use future information unavailable in live operation. Different cost functions detect different kinds of change, and no single penalty is universally appropriate.
Business use
Use segmentation to make long sequences interpretable and to identify periods needing investigation. Report the feature representation, cost, search method, penalty, and minimum segment length. Keep detected boundaries separate from confirmed operational events, and evaluate live detection separately when decisions must be made in real time.
People also ask
Must segments have constant means?
No; that is one possible model.
Does segmentation require knowing the number of changes?
No; penalized methods can select it.
Can a smooth trend create apparent segments?
Yes, particularly if a piecewise-constant model approximates it.
Check your understanding
What is the no-boundary cost in the example?
Answer: Eighty-two.
Where is the best single split?
Answer: After the third observation.
Why does a larger penalty change the decision?
Answer: It charges more for additional model complexity.
Related terms
- Structural break
- Dynamic programming
- Regularization
- Time series
- Change-point detection
- piecewise model
- PELT
- online detection
Learn next
Compare mean-change and variance-change costs, then study offline and online change detection. Test sensitivity to penalties and minimum segment lengths before interpreting boundaries as meaningful regimes.
More in Statistics and probability
- Tetrachoric correlation - Tetrachoric correlation estimates the correlation between two hypothetical continuous variables from two observed binary variables, assuming the continuous...
- Time origin - The time origin is the reference point from which elapsed time is measured in a study or analysis.
- Time series breaks - Time series breaks are discontinuities in comparability caused by changes in how a variable is defined, classified, covered, measured, or compiled over time.
- Time-varying covariate - A time-varying covariate is a predictor whose value can change during the period being analyzed.
- Time Warp Edit Distance - Time Warp Edit Distance, abbreviated TWED or TWE, is an elastic distance for comparing time series through a minimum-cost sequence of matching and editing...
- Tolerance - Tolerance is a regression diagnostic that measures how much of one predictor's variation remains unexplained by the other predictors in the model.
Sources
Truong, Oudre and Vayatis, ruptures: change point detection in Python: https://arxiv.org/abs/1801.00826 ruptures, PELT documentation: https://centre-borelli.github.io/ruptures-docs/code-reference/detection/pelt-reference/ ruptures, Window sliding segmentation: https://centre-borelli.github.io/ruptures-docs/user-guide/detection/window/ The six-point segmentation example is original.
Previous: Time series model Next: Time to answer