|
10 | 10 | merge_category_columns, |
11 | 11 | ) |
12 | 12 | from ads.opctl.operator.lowcode.common.data import AbstractData |
13 | | -from ads.opctl.operator.lowcode.common.data import AbstractData |
14 | 13 | from ads.opctl.operator.lowcode.anomaly.utils import get_frequency_of_datetime |
15 | 14 | from ads.opctl import logger |
16 | 15 | import pandas as pd |
@@ -56,6 +55,10 @@ def __init__(self, spec: AnomalyOperatorSpec): |
56 | 55 | self.X_valid_dict = self.valid_data.X_valid_dict |
57 | 56 | self.y_valid_dict = self.valid_data.y_valid_dict |
58 | 57 |
|
| 58 | + # Returns raw data based on the series_id i.e; the merged target_category_column value |
| 59 | + def get_raw_data_by_cat(self, category): |
| 60 | + return self._data.get_raw_data_by_cat(category) |
| 61 | + |
59 | 62 |
|
60 | 63 | class AnomalyOutput: |
61 | 64 | def __init__(self, date_column): |
@@ -94,38 +97,28 @@ def get_outliers_by_cat(self, category: str, data: pd.DataFrame): |
94 | 97 | outliers = pd.merge(outliers, scores, on=self.date_column, how="inner") |
95 | 98 | return outliers |
96 | 99 |
|
97 | | - def get_inliers(self, data): |
| 100 | + def get_inliers(self, datasets): |
98 | 101 | inliers = pd.DataFrame() |
99 | 102 |
|
100 | 103 | for category in self.list_categories(): |
101 | 104 | inliers = pd.concat( |
102 | 105 | [ |
103 | 106 | inliers, |
104 | | - self.get_inliers_by_cat( |
105 | | - category, |
106 | | - data[data[OutputColumns.Series] == category] |
107 | | - .reset_index(drop=True) |
108 | | - .drop(OutputColumns.Series, axis=1), |
109 | | - ), |
| 107 | + self.get_inliers_by_cat(category, datasets.get_raw_data_by_cat(category)), |
110 | 108 | ], |
111 | 109 | axis=0, |
112 | 110 | ignore_index=True, |
113 | 111 | ) |
114 | 112 | return inliers |
115 | 113 |
|
116 | | - def get_outliers(self, data): |
| 114 | + def get_outliers(self, datasets): |
117 | 115 | outliers = pd.DataFrame() |
118 | 116 |
|
119 | 117 | for category in self.list_categories(): |
120 | 118 | outliers = pd.concat( |
121 | 119 | [ |
122 | 120 | outliers, |
123 | | - self.get_outliers_by_cat( |
124 | | - category, |
125 | | - data[data[OutputColumns.Series] == category] |
126 | | - .reset_index(drop=True) |
127 | | - .drop(OutputColumns.Series, axis=1), |
128 | | - ), |
| 121 | + self.get_outliers_by_cat(category, datasets.get_raw_data_by_cat(category)), |
129 | 122 | ], |
130 | 123 | axis=0, |
131 | 124 | ignore_index=True, |
|
0 commit comments