@@ -505,16 +505,26 @@ def get_new_params(method='random'):
505505 'smape_weighting' : random .choices ([0 , 1 , 5 , 10 ], [0.3 , 0.2 , 0.3 , 0.1 ])[
506506 0
507507 ],
508- 'mae_weighting' : random .choices ([0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ])[0 ],
509- 'rmse_weighting' : random .choices ([0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ])[0 ],
508+ 'mae_weighting' : random .choices (
509+ [0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ]
510+ )[0 ],
511+ 'rmse_weighting' : random .choices (
512+ [0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ]
513+ )[0 ],
510514 'made_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.7 , 0.3 , 0.1 , 0.05 ])[
511515 0
512516 ],
513- 'mage_weighting' : random .choices ([0 , 1 , 3 , 5 , 0.01 ], [0.8 , 0.1 , 0.1 , 0.0 , 0.2 ])[0 ],
517+ 'mage_weighting' : random .choices (
518+ [0 , 1 , 3 , 5 , 0.01 ], [0.8 , 0.1 , 0.1 , 0.0 , 0.2 ]
519+ )[0 ],
514520 'mle_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.8 , 0.1 , 0.1 , 0.0 ])[0 ],
515521 'imle_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.8 , 0.1 , 0.1 , 0.0 ])[0 ],
516- 'spl_weighting' : random .choices ([0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ])[0 ],
517- 'oda_weighting' : random .choices ([0 , 1 , 3 , 5 , 0.1 ], [0.8 , 0.1 , 0.1 , 0.0 , 0.1 ])[0 ],
522+ 'spl_weighting' : random .choices (
523+ [0 , 1 , 3 , 5 , 0.1 ], [0.1 , 0.3 , 0.3 , 0.3 , 0.1 ]
524+ )[0 ],
525+ 'oda_weighting' : random .choices (
526+ [0 , 1 , 3 , 5 , 0.1 ], [0.8 , 0.1 , 0.1 , 0.0 , 0.1 ]
527+ )[0 ],
518528 'mqae_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.4 , 0.2 , 0.1 , 0.0 ])[0 ],
519529 'dwae_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.8 , 0.1 , 0.1 , 0.0 ])[0 ],
520530 'maxe_weighting' : random .choices ([0 , 1 , 3 , 5 ], [0.8 , 0.1 , 0.1 , 0.0 ])[0 ],
@@ -1544,7 +1554,9 @@ def validation_agg(self):
15441554 )
15451555 return self
15461556
1547- def _return_best_model (self , metric_weighting = None , allow_horizontal = True , n = 1 , template_cols = None ):
1557+ def _return_best_model (
1558+ self , metric_weighting = None , allow_horizontal = True , n = 1 , template_cols = None
1559+ ):
15481560 """Sets best model based on validation results.
15491561
15501562 Args:
@@ -1614,7 +1626,9 @@ def _set_best_model(self, metric_weighting=None, allow_horizontal=True, n=1):
16141626 self .parse_best_model ()
16151627 return self
16161628
1617- def _best_non_horizontal (self , metric_weighting = None , series = None , n = 1 , template_cols = None ):
1629+ def _best_non_horizontal (
1630+ self , metric_weighting = None , series = None , n = 1 , template_cols = None
1631+ ):
16181632 if self .validation_results is None :
16191633 if not self .initial_results .model_results .empty :
16201634 self = self .validation_agg ()
@@ -2177,10 +2191,14 @@ def export_template(
21772191 extra_mods = []
21782192 if min_metrics is not None :
21792193 for metric in min_metrics :
2180- extra_mods .append (export_template .nsmallest (1 , columns = metric ).copy ())
2194+ extra_mods .append (
2195+ export_template .nsmallest (1 , columns = metric ).copy ()
2196+ )
21812197 if max_metrics is not None :
21822198 for metric in max_metrics :
2183- extra_mods .append (export_template .nlargest (1 , columns = metric ).copy ())
2199+ extra_mods .append (
2200+ export_template .nlargest (1 , columns = metric ).copy ()
2201+ )
21842202 if str (max_per_model_class ).isdigit ():
21852203 export_template = (
21862204 export_template .sort_values ('Score' , ascending = True )
@@ -2191,7 +2209,9 @@ def export_template(
21912209 export_template = export_template .nsmallest (n , columns = ['Score' ])
21922210 if extra_mods :
21932211 extra_mods = pd .concat (extra_mods )
2194- export_template = pd .concat ([export_template , extra_mods ]).drop_duplicates ()
2212+ export_template = pd .concat (
2213+ [export_template , extra_mods ]
2214+ ).drop_duplicates ()
21952215 if self .best_model_id not in export_template ['ID' ]:
21962216 export_template = pd .concat (
21972217 [
@@ -2469,12 +2489,22 @@ def _generate_mosaic_template(
24692489 )
24702490 runtime_weighting = self .metric_weighting .get ("runtime_weighting" , 0 )
24712491 if runtime_weighting != 0 :
2472- local_results = initial_results .model_results .copy ().groupby ("ID" )["TotalRuntimeSeconds" ].mean ()
2473- runtimes = local_results .loc [initial_results .full_mae_ids ].to_numpy ()[:, np .newaxis , np .newaxis ]
2492+ local_results = (
2493+ initial_results .model_results .copy ()
2494+ .groupby ("ID" )["TotalRuntimeSeconds" ]
2495+ .mean ()
2496+ )
2497+ runtimes = local_results .loc [initial_results .full_mae_ids ].to_numpy ()[
2498+ :, np .newaxis , np .newaxis
2499+ ]
24742500 # not fully confident in this scaler, trying to put runtime loosely in reference to mae scale
2475- mae_min = initial_results .per_series_mae .loc [initial_results .model_results .set_index ("ID" )['mae' ].idxmin ()]
2501+ mae_min = initial_results .per_series_mae .loc [
2502+ initial_results .model_results .set_index ("ID" )['mae' ].idxmin ()
2503+ ]
24762504 mae_min = np .min (mae_min [mae_min > 0 ])
2477- basic_scaler = initial_results .model_results ['TotalRuntimeSeconds' ].mean () / mae_min
2505+ basic_scaler = (
2506+ initial_results .model_results ['TotalRuntimeSeconds' ].mean () / mae_min
2507+ )
24782508 # making runtime weighting even smaller because generally want this to be a very small component
24792509 weight_per_value + (runtimes / basic_scaler ) * (runtime_weighting / 10 )
24802510
@@ -2496,7 +2526,9 @@ def _generate_mosaic_template(
24962526 # process for crosshair
24972527 crs_hr = mosaic_config .get ("crosshair" )
24982528 if crs_hr :
2499- full_mae_err = [generate_crosshair_score (x , method = crs_hr ) for x in errs ]
2529+ full_mae_err = [
2530+ generate_crosshair_score (x , method = crs_hr ) for x in errs
2531+ ]
25002532 else :
25012533 full_mae_err = errs
25022534 # refine to n_models if necessary
0 commit comments