-
-
Notifications
You must be signed in to change notification settings - Fork 47
fix Prophet insufficient data error in detect_anomalies #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0746cf2
4af3f43
e8cdfc2
14fbf53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |||||
| from gluonts.time_feature.seasonality import ( | ||||||
| get_seasonality as _get_seasonality, | ||||||
| ) | ||||||
| from prophet import Prophet as ProphetBase | ||||||
| from scipy import stats | ||||||
| from tqdm import tqdm | ||||||
| from utilsforecast.plotting import plot_series | ||||||
|
|
@@ -304,6 +305,7 @@ def detect_anomalies( | |||||
| Args: | ||||||
| df (pd.DataFrame): | ||||||
| DataFrame containing the time series to detect anomalies. | ||||||
| Minimum series length is 1 higher for Prophet than other models. | ||||||
| h (int, optional): | ||||||
| Forecast horizon specifying how many future steps to predict. | ||||||
| In each cross validation window. If not provided, the seasonality | ||||||
|
|
@@ -348,14 +350,19 @@ def detect_anomalies( | |||||
| min_series_length = df.groupby("unique_id").size().min() | ||||||
| # we require at least one observation before the first forecast | ||||||
| max_possible_windows = (min_series_length - 1) // h | ||||||
| # 3 row minimum for a df with Prophet | ||||||
|
||||||
| # 3 row minimum for a df with Prophet | |
| # Prophet requires min_series_length >= 2h + 1, where h is the forecast horizon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation comment is unclear and potentially misleading. It states "Minimum series length is 1 higher for Prophet than other models" but doesn't specify what that minimum is. Consider being more explicit, e.g., "For Prophet models, the minimum series length is
h + 2instead ofh + 1."