19
19
from ads .common .decorator .runtime_dependency import runtime_dependency
20
20
from ads .common .object_storage_details import ObjectStorageDetails
21
21
from ads .opctl import logger
22
+ from ads .opctl .operator .lowcode .common .const import DataColumns
22
23
from ads .opctl .operator .lowcode .common .utils import (
23
24
datetime_to_seconds ,
24
25
disable_print ,
28
29
seconds_to_datetime ,
29
30
write_data ,
30
31
)
31
- from ads .opctl .operator .lowcode .common .const import DataColumns
32
32
from ads .opctl .operator .lowcode .forecast .model .forecast_datasets import TestData
33
33
from ads .opctl .operator .lowcode .forecast .utils import (
34
34
_build_metrics_df ,
49
49
SpeedAccuracyMode ,
50
50
SupportedMetrics ,
51
51
SupportedModels ,
52
- BACKTEST_REPORT_NAME ,
53
52
)
54
53
from ..operator_config import ForecastOperatorConfig , ForecastOperatorSpec
55
54
from .forecast_datasets import ForecastDatasets
@@ -127,8 +126,9 @@ def generate_report(self):
127
126
if self .spec .generate_report or self .spec .generate_metrics :
128
127
self .eval_metrics = self .generate_train_metrics ()
129
128
if not self .target_cat_col :
130
- self .eval_metrics .rename ({"Series 1" : self .original_target_column },
131
- axis = 1 , inplace = True )
129
+ self .eval_metrics .rename (
130
+ {"Series 1" : self .original_target_column }, axis = 1 , inplace = True
131
+ )
132
132
133
133
if self .spec .test_data :
134
134
try :
@@ -140,8 +140,11 @@ def generate_report(self):
140
140
elapsed_time = elapsed_time ,
141
141
)
142
142
if not self .target_cat_col :
143
- self .test_eval_metrics .rename ({"Series 1" : self .original_target_column },
144
- axis = 1 , inplace = True )
143
+ self .test_eval_metrics .rename (
144
+ {"Series 1" : self .original_target_column },
145
+ axis = 1 ,
146
+ inplace = True ,
147
+ )
145
148
except Exception :
146
149
logger .warn ("Unable to generate Test Metrics." )
147
150
logger .debug (f"Full Traceback: { traceback .format_exc ()} " )
@@ -223,17 +226,23 @@ def generate_report(self):
223
226
rc .Block (
224
227
first_10_title ,
225
228
# series_subtext,
226
- rc .Select (blocks = first_5_rows_blocks ) if self .target_cat_col else first_5_rows_blocks [0 ],
229
+ rc .Select (blocks = first_5_rows_blocks )
230
+ if self .target_cat_col
231
+ else first_5_rows_blocks [0 ],
227
232
),
228
233
rc .Block (
229
234
last_10_title ,
230
235
# series_subtext,
231
- rc .Select (blocks = last_5_rows_blocks ) if self .target_cat_col else last_5_rows_blocks [0 ],
236
+ rc .Select (blocks = last_5_rows_blocks )
237
+ if self .target_cat_col
238
+ else last_5_rows_blocks [0 ],
232
239
),
233
240
rc .Block (
234
241
summary_title ,
235
242
# series_subtext,
236
- rc .Select (blocks = data_summary_blocks ) if self .target_cat_col else data_summary_blocks [0 ],
243
+ rc .Select (blocks = data_summary_blocks )
244
+ if self .target_cat_col
245
+ else data_summary_blocks [0 ],
237
246
),
238
247
rc .Separator (),
239
248
)
@@ -308,7 +317,7 @@ def generate_report(self):
308
317
horizon = self .spec .horizon ,
309
318
test_data = test_data ,
310
319
ci_interval_width = self .spec .confidence_interval_width ,
311
- target_category_column = self .target_cat_col
320
+ target_category_column = self .target_cat_col ,
312
321
)
313
322
if (
314
323
series_name is not None
@@ -491,7 +500,11 @@ def _save_report(
491
500
f2 .write (f1 .read ())
492
501
493
502
# forecast csv report
494
- result_df = result_df if self .target_cat_col else result_df .drop (DataColumns .Series , axis = 1 )
503
+ result_df = (
504
+ result_df
505
+ if self .target_cat_col
506
+ else result_df .drop (DataColumns .Series , axis = 1 )
507
+ )
495
508
write_data (
496
509
data = result_df ,
497
510
filename = os .path .join (unique_output_dir , self .spec .forecast_filename ),
@@ -667,7 +680,10 @@ def _save_model(self, output_dir, storage_options):
667
680
)
668
681
669
682
def _validate_automlx_explanation_mode (self ):
670
- if self .spec .model != SupportedModels .AutoMLX and self .spec .explanations_accuracy_mode == SpeedAccuracyMode .AUTOMLX :
683
+ if (
684
+ self .spec .model != SupportedModels .AutoMLX
685
+ and self .spec .explanations_accuracy_mode == SpeedAccuracyMode .AUTOMLX
686
+ ):
671
687
raise ValueError (
672
688
"AUTOMLX explanation accuracy mode is only supported for AutoMLX models. "
673
689
"Please select mode other than AUTOMLX from the available explanations_accuracy_mode options"
@@ -738,14 +754,14 @@ def explain_model(self):
738
754
logger .warn (
739
755
"No explanations generated. Ensure that additional data has been provided."
740
756
)
741
- elif (
742
- self .spec .model == SupportedModels .AutoMLX
743
- and self .spec .explanations_accuracy_mode
744
- == SpeedAccuracyMode .AUTOMLX
745
- ):
746
- logger .warning (
747
- "Global explanations not available for AutoMLX models with inherent explainability"
748
- )
757
+ # elif (
758
+ # self.spec.model == SupportedModels.AutoMLX
759
+ # and self.spec.explanations_accuracy_mode
760
+ # == SpeedAccuracyMode.AUTOMLX
761
+ # ):
762
+ # logger.warning(
763
+ # "Global explanations not available for AutoMLX models with inherent explainability"
764
+ # )
749
765
else :
750
766
self .global_explanation [s_id ] = dict (
751
767
zip (
0 commit comments