Skip to content

Commit

Permalink
fix(model): remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Amatullah committed Oct 13, 2022
1 parent 83ed135 commit a3f03ff
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions chaos_genius/core/anomaly/models/standard_deviation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,4 @@ def predict(
df["yhat_upper"] = threshold_u
df["yhat"] = (threshold_l + threshold_u) / 2

df_anomaly = self._detect_anomalies(df)
df_anomaly = df_anomaly[["dt", "yhat", "yhat_lower", "yhat_upper"]]

return df_anomaly

def _detect_anomalies(self, forecast):
forecasted = forecast[["ds", "yhat", "yhat_lower", "yhat_upper", "y"]].copy()
forecasted["anomaly"] = 0

forecasted.loc[forecasted["y"] > forecasted["yhat_upper"], "anomaly"] = 1

forecasted.loc[forecasted["y"] < forecasted["yhat_lower"], "anomaly"] = -1

# anomaly importances

forecasted["importance"] = 0
forecasted.loc[forecasted["anomaly"] == 1, "importance"] = (
forecasted["y"] - forecasted["yhat_upper"]
) / forecast["y"]

forecasted.loc[forecasted["anomaly"] == -1, "importance"] = (
forecasted["yhat_lower"] - forecasted["y"]
) / forecast["y"]

return forecasted
return df[["dt", "yhat", "yhat_lower", "yhat_upper"]]

0 comments on commit a3f03ff

Please sign in to comment.