fix: handle expected value less than zero (#7410)

This commit is contained in:
Srikanth Chekuri 2025-03-26 18:20:46 +05:30 committed by GitHub
parent 72207691a3
commit 8f095dfbc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -313,6 +313,9 @@ func (p *BaseSeasonalProvider) getScore(
series, prevSeries, weekSeries, weekPrevSeries, past2SeasonSeries, past3SeasonSeries *v3.Series, value float64, idx int,
) float64 {
expectedValue := p.getExpectedValue(series, prevSeries, weekSeries, weekPrevSeries, past2SeasonSeries, past3SeasonSeries, idx)
if expectedValue < 0 {
expectedValue = p.getMovingAvg(prevSeries, movingAvgWindowSize, idx)
}
return (value - expectedValue) / p.getStdDev(weekSeries)
}