3535]
3636
3737
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+ ):
3941 utc = pytz .utc
4042 predictions = time_series_arima_plus_model .predict ().to_pandas ()
4143 assert predictions .shape == (3 , 8 )
@@ -63,7 +65,7 @@ def test_model_predict_default(time_series_arima_plus_model: forecasting.ARIMAPl
6365 )
6466
6567
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 ):
6769 utc = pytz .utc
6870 predictions = time_series_arima_plus_model .predict (
6971 horizon = 4 , confidence_level = 0.9
@@ -94,7 +96,55 @@ def test_model_predict_params(time_series_arima_plus_model: forecasting.ARIMAPlu
9496 )
9597
9698
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 (
98148 time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
99149):
100150 result = time_series_arima_plus_model .score (
@@ -118,16 +168,14 @@ def test_model_score(
118168 )
119169
120170
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 ):
124172 result = time_series_arima_plus_model .summary ()
125173 assert result .shape == (1 , 12 )
126174 assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
127175
128176
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 ,
131179):
132180 result = time_series_arima_plus_model .summary (
133181 show_all_candidate_models = True ,
@@ -136,7 +184,7 @@ def test_model_summary_show_all_candidates(
136184 assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
137185
138186
139- def test_model_score_series (
187+ def test_arima_plus_score_series (
140188 time_series_arima_plus_model : forecasting .ARIMAPlus , new_time_series_df
141189):
142190 result = time_series_arima_plus_model .score (
@@ -160,9 +208,7 @@ def test_model_score_series(
160208 )
161209
162210
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 ):
166212 result = time_series_arima_plus_model .summary ()
167213 assert result .shape == (1 , 12 )
168214 assert all (column in result .columns for column in ARIMA_EVALUATE_OUTPUT_COL )
0 commit comments