Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

fix(model): remove deprecated functions #1152

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]]