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

fix(anomaly): ensure correct data types #1077

Merged
merged 1 commit into from
Aug 8, 2022
Merged
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: 13 additions & 13 deletions chaos_genius/core/anomaly/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from typing import Dict, Tuple, Union

import numpy as np
import pandas as pd

from chaos_genius.core.anomaly.constants import FREQUENCY_DELTA
Expand Down Expand Up @@ -105,16 +106,17 @@ def _predict(self, model: AnomalyModel) -> pd.DataFrame:
"""
input_data = self.input_data

pred_series = pd.DataFrame(
columns=[
"dt",
"y",
"yhat_lower",
"yhat_upper",
"anomaly",
"severity",
"impact",
]
pred_series_schema = {
"dt": np.datetime64,
"y": float,
"yhat_lower": float,
"yhat_upper": float,
"anomaly": int,
"severity": float,
"impact": float,
}
pred_series = pd.DataFrame(columns=pred_series_schema.keys()).astype(
pred_series_schema
)

input_last_date = input_data["dt"].iloc[-1]
Expand Down Expand Up @@ -169,9 +171,7 @@ def _predict(self, model: AnomalyModel) -> pd.DataFrame:
)
prediction["y"] = df["y"].to_list()

prediction = pd.DataFrame(prediction.iloc[-1].copy()).T.reset_index(
drop=True
)
prediction = prediction.iloc[[-1]]

pred_series = pred_series.append(
self._calculate_metrics(
Expand Down