# Piecewise regression: When one line simply isn't enough

DevFeed: [Piecewise regression: When one line simply isn't enough](<https://devfeed.tech/articles/piecewise-regression-when-one-line-simply-isn-t-enough-83488.md>)

Original publisher: [Read original article](<https://www.datadoghq.com/blog/engineering/piecewise-regression/>)

Author: Stephen Kappel

Published: 2017-07-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [Datadog](<https://devfeed.tech/sources/datadog.md>)

Topics: [linear-regression](<https://devfeed.tech/topics/linear-regression.md>), [plotting](<https://devfeed.tech/topics/plotting.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>)

Tags: [dataset](<https://devfeed.tech/tags/dataset.md>), [dynamic-programming](<https://devfeed.tech/tags/dynamic-programming.md>), [graphs](<https://devfeed.tech/tags/graphs.md>), [greedy-algorithm](<https://devfeed.tech/tags/greedy-algorithm.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [python](<https://devfeed.tech/tags/python.md>), [regression](<https://devfeed.tech/tags/regression.md>)

## AI overview

Datadog describes a greedy algorithm for automatically fitting piecewise regression to time-series data. The method selects breakpoints and a segment count, then merges neighboring segments based on the increase in error, using a stopping criterion to balance fit quality with model simplicity.

## Source excerpt

A piecewise regression can model multiple trends in a single data set. Learn how Datadog automates piecewise regression on our timeseries data.