Skip to content

Commit 4af3f43

Browse files
committed
min series length requirements for Prophet in detect_anomalies
note in docstring on higher min series length for Prophet update error message to reflect Prophet's series length requirements
1 parent 0746cf2 commit 4af3f43

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

timecopilot/models/utils/forecaster.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ def detect_anomalies(
305305
Args:
306306
df (pd.DataFrame):
307307
DataFrame containing the time series to detect anomalies.
308+
Minimum series length is 1 higher for Prophet than other models.
308309
h (int, optional):
309310
Forecast horizon specifying how many future steps to predict.
310311
In each cross validation window. If not provided, the seasonality
@@ -357,9 +358,11 @@ def detect_anomalies(
357358
else:
358359
_n_windows = min(n_windows, max_possible_windows)
359360
if _n_windows < 1:
361+
# min series length should be 1 higher for Prophet than other models
362+
exp_min_series_length = h + 1 if isinstance(self, ProphetBase) else h + 2
360363
raise ValueError(
361364
f"Cannot perform anomaly detection: series too short. "
362-
f"Minimum series length required: {h + 1}, "
365+
f"Minimum series length required: {exp_min_series_length}, "
363366
f"actual minimum length: {min_series_length}"
364367
)
365368
cv_results = self.cross_validation(

0 commit comments

Comments
 (0)