elastic / ml-cpp

Machine learning C++ code
Other
7 stars 62 forks source link

[ML] Improve forecasting for time series with step changes #2591

Closed tveasey closed 1 year ago

tveasey commented 1 year ago

We model the level of a time series which we've observed having step discontinuities via a Markov process for forecasting. Specifically, we estimate the historical step size distribution and the distribution of the steps in time and as a function of the time series value. For this second part we use an online naive Bayes model to estimate the probability that at any given point in a roll out for forecasting we will get a step.

This approach generally works well unless we're in the tails of the distribution values we've observed for the time series historically when we roll out. In this case, our prediction probability are very sensitive to the tail behaviour of the distributions we fit to the time series values where we saw a step and sometimes we predict far too many steps as a result. We can detect this case: when we're in the tails of time series value distribution.

This change does this and stops predicting changes in such cases, which avoids pathologies. This fixes #2466.

yomduf commented 11 months ago

Do you think it would be possible that Fix could be applied to v8.11.?

tveasey commented 11 months ago

Done in #2597.