Skip to content

Commit

Permalink
Add fix for zero division in performance_metrics().
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasChia committed May 1, 2024
1 parent c00f6a2 commit 03d5bfa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions python/prophet/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def smape(df, w):
Dataframe with columns horizon and smape.
"""
sape = np.abs(df['y'] - df['yhat']) / ((np.abs(df['y']) + np.abs(df['yhat'])) / 2)
sape = sape.fillna(0)
if w < 0:
return pd.DataFrame({'horizon': df['horizon'], 'smape': sape})
return rolling_mean_by_h(
Expand Down

0 comments on commit 03d5bfa

Please sign in to comment.