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