35
35
]
36
36
37
37
38
- def test_model_predict_default (time_series_arima_plus_model : forecasting .ARIMAPlus ):
38
+ def test_arima_plus_predict_default (
39
+ time_series_arima_plus_model : forecasting .ARIMAPlus ,
40
+ ):
39
41
utc = pytz .utc
40
42
predictions = time_series_arima_plus_model .predict ().to_pandas ()
41
43
assert predictions .shape == (3 , 8 )
@@ -63,7 +65,7 @@ def test_model_predict_default(time_series_arima_plus_model: forecasting.ARIMAPl
63
65
)
64
66
65
67
66
- def test_model_predict_params (time_series_arima_plus_model : forecasting .ARIMAPlus ):
68
+ def test_arima_plus_predict_params (time_series_arima_plus_model : forecasting .ARIMAPlus ):
67
69
utc = pytz .utc
68
70
predictions = time_series_arima_plus_model .predict (
69
71
horizon = 4 , confidence_level = 0.9
@@ -94,7 +96,55 @@ def test_model_predict_params(time_series_arima_plus_model: forecasting.ARIMAPlu
94
96
)
95
97
96
98
97
- def test_model_score (
99
+ def test_arima_plus_detect_anomalies (
100
+ time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
101
+ ):
102
+ anomalies = time_series_arima_plus_model .detect_anomalies (
103
+ new_time_series_df
104
+ ).to_pandas ()
105
+
106
+ expected = pd .DataFrame (
107
+ {
108
+ "is_anomaly" : [False , False , False ],
109
+ "lower_bound" : [2349.301736 , 2153.614829 , 1849.040192 ],
110
+ "upper_bound" : [3099.642833 , 3033.12195 , 2858.185876 ],
111
+ "anomaly_probability" : [0.757824 , 0.322559 , 0.43011 ],
112
+ },
113
+ )
114
+ pd .testing .assert_frame_equal (
115
+ anomalies [["is_anomaly" , "lower_bound" , "upper_bound" , "anomaly_probability" ]],
116
+ expected ,
117
+ rtol = 0.1 ,
118
+ check_index_type = False ,
119
+ check_dtype = False ,
120
+ )
121
+
122
+
123
+ def test_arima_plus_detect_anomalies_params (
124
+ time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
125
+ ):
126
+ anomalies = time_series_arima_plus_model .detect_anomalies (
127
+ new_time_series_df , anomaly_prob_threshold = 0.7
128
+ ).to_pandas ()
129
+
130
+ expected = pd .DataFrame (
131
+ {
132
+ "is_anomaly" : [True , False , False ],
133
+ "lower_bound" : [2525.5363 , 2360.1870 , 2086.0609 ],
134
+ "upper_bound" : [2923.408256 , 2826.54981 , 2621.165188 ],
135
+ "anomaly_probability" : [0.757824 , 0.322559 , 0.43011 ],
136
+ },
137
+ )
138
+ pd .testing .assert_frame_equal (
139
+ anomalies [["is_anomaly" , "lower_bound" , "upper_bound" , "anomaly_probability" ]],
140
+ expected ,
141
+ rtol = 0.1 ,
142
+ check_index_type = False ,
143
+ check_dtype = False ,
144
+ )
145
+
146
+
147
+ def test_arima_plus_score (
98
148
time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
99
149
):
100
150
result = time_series_arima_plus_model .score (
@@ -118,16 +168,14 @@ def test_model_score(
118
168
)
119
169
120
170
121
- def test_model_summary (
122
- time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
123
- ):
171
+ def test_arima_plus_summary (time_series_arima_plus_model : forecasting .ARIMAPlus ):
124
172
result = time_series_arima_plus_model .summary ()
125
173
assert result .shape == (1 , 12 )
126
174
assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
127
175
128
176
129
- def test_model_summary_show_all_candidates (
130
- time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
177
+ def test_arima_plus_summary_show_all_candidates (
178
+ time_series_arima_plus_model : forecasting .ARIMAPlus ,
131
179
):
132
180
result = time_series_arima_plus_model .summary (
133
181
show_all_candidate_models = True ,
@@ -136,7 +184,7 @@ def test_model_summary_show_all_candidates(
136
184
assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
137
185
138
186
139
- def test_model_score_series (
187
+ def test_arima_plus_score_series (
140
188
time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
141
189
):
142
190
result = time_series_arima_plus_model .score (
@@ -160,9 +208,7 @@ def test_model_score_series(
160
208
)
161
209
162
210
163
- def test_model_summary_series (
164
- time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
165
- ):
211
+ def test_arima_plus_summary_series (time_series_arima_plus_model : forecasting .ARIMAPlus ):
166
212
result = time_series_arima_plus_model .summary ()
167
213
assert result .shape == (1 , 12 )
168
214
assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
0 commit comments