47
47
SpeedAccuracyMode ,
48
48
SupportedMetrics ,
49
49
SupportedModels ,
50
+ SpeedAccuracyMode ,
51
+ AUTO_SELECT ,
52
+ BACKTEST_REPORT_NAME
50
53
)
51
54
from ..operator_config import ForecastOperatorConfig , ForecastOperatorSpec
52
55
from .forecast_datasets import ForecastDatasets
@@ -255,12 +258,9 @@ def generate_report(self):
255
258
256
259
backtest_sections = []
257
260
output_dir = self .spec .output_directory .url
258
- backtest_report_name = "backtest_stats.csv"
259
- file_path = f"{ output_dir } /{ backtest_report_name } "
261
+ file_path = f"{ output_dir } /{ BACKTEST_REPORT_NAME } "
260
262
if self .spec .model == AUTO_SELECT :
261
- backtest_sections .append (
262
- rc .Heading ("Auto-select statistics" , level = 2 )
263
- )
263
+ backtest_sections .append (rc .Heading ("Auto-Select Backtesting and Performance Metrics" , level = 2 ))
264
264
if not os .path .exists (file_path ):
265
265
failure_msg = rc .Text (
266
266
"auto-select could not be executed. Please check the "
@@ -269,19 +269,15 @@ def generate_report(self):
269
269
backtest_sections .append (failure_msg )
270
270
else :
271
271
backtest_stats = pd .read_csv (file_path )
272
- average_dict = backtest_stats .mean (). to_dict ( )
273
- del average_dict [ "backtest" ]
272
+ model_metric_map = backtest_stats .drop ( columns = [ 'metric' , 'backtest' ] )
273
+ average_dict = { k : round ( v , 4 ) for k , v in model_metric_map . mean (). to_dict (). items ()}
274
274
best_model = min (average_dict , key = average_dict .get )
275
- backtest_text = rc .Heading ("Back Testing Metrics" , level = 3 )
276
275
summary_text = rc .Text (
277
- f"Overall, the average scores for the models are { average_dict } , with { best_model } "
278
- f" being identified as the top-performing model during backtesting."
279
- )
276
+ f"Overall, the average { self .spec .metric } scores for the models are { average_dict } , with"
277
+ f" { best_model } being identified as the top-performing model during backtesting." )
280
278
backtest_table = rc .DataTable (backtest_stats , index = True )
281
279
liner_plot = get_auto_select_plot (backtest_stats )
282
- backtest_sections .extend (
283
- [backtest_text , backtest_table , summary_text , liner_plot ]
284
- )
280
+ backtest_sections .extend ([backtest_table , summary_text , liner_plot ])
285
281
286
282
forecast_plots = []
287
283
if len (self .forecast_output .list_series_ids ()) > 0 :
0 commit comments