Skip to content

Commit 0746cf2

Browse files
committed
fix Prophet insufficient data error in detect_anomalies
1 parent b85ac48 commit 0746cf2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

timecopilot/models/utils/forecaster.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from gluonts.time_feature.seasonality import (
1010
get_seasonality as _get_seasonality,
1111
)
12+
from prophet import Prophet as ProphetBase
1213
from scipy import stats
1314
from tqdm import tqdm
1415
from utilsforecast.plotting import plot_series
@@ -348,6 +349,9 @@ def detect_anomalies(
348349
min_series_length = df.groupby("unique_id").size().min()
349350
# we require at least one observation before the first forecast
350351
max_possible_windows = (min_series_length - 1) // h
352+
# 3 row minimum for a df with Prophet
353+
if isinstance(self, ProphetBase):
354+
max_possible_windows -= 1
351355
if n_windows is None:
352356
_n_windows = max_possible_windows
353357
else:

0 commit comments

Comments
 (0)