@@ -780,29 +780,38 @@ def evaluate_challenge(self) -> None:
780780 ]
781781 df = pd .DataFrame (
782782 {
783+ "initial_mae" : [episode .maes ()[0 ] for episode in self .episodes ],
783784 "final_mae" : final_mae ,
784785 "steps_to_convergence" : steps_to_convergence ,
785786 "sum_of_normalized_magnet_changes" : sum_of_normalized_magnet_changes ,
786787 }
787788 )
789+ # Validate steps to convergence (should be max steps if final MAE is not less
790+ # than final MAE)
791+ df ["steps_to_convergence" ] = df .apply (
792+ lambda row : (
793+ row ["steps_to_convergence" ]
794+ if row ["final_mae" ] < row ["initial_mae" ]
795+ else 150
796+ ),
797+ axis = 1 ,
798+ )
788799 Path ("data/csvs" ).mkdir (exist_ok = True )
789800 if Path (f"data/csvs/{ self .name } .csv" ).exists ():
790801 print (f"Overwriting existing file data/csvs/{ self .name } .csv" )
791802 df .to_csv (f"data/csvs/{ self .name } .csv" , index_label = "id" )
792803
793804 # Output evaluation results
794- print (f"Final MAE: { self .median_final_mae () * 1e6 :.0f} μm" )
795- print (
796- f"Steps to convergence: { self .median_steps_to_convergence (threshold = 4e-5 )} "
797- )
805+ print (f"Final MAE: { df ['final_mae' ].median () * 1e6 :.0f} μm" )
806+ print (f"Steps to convergence: { df ['steps_to_convergence' ].median ():.1f} " )
798807 print (
799- f"Sum of magnet changes: { self . median_sum_of_normalized_magnet_changes ():.2f} "
808+ f"Sum of magnet changes: { df [ 'sum_of_normalized_magnet_changes' ]. median ():.2f} "
800809 )
801810
802811 score = (
803- df ["final_mae" ] / 4_000
804- + df ["steps_to_convergence" ] / 150
805- + df ["sum_of_normalized_magnet_changes" ] / (5 * 150 )
812+ 3 * df ["final_mae" ] / 4_000
813+ + 0.5 * df ["steps_to_convergence" ] / 150
814+ + 0.5 * df ["sum_of_normalized_magnet_changes" ] / (5 * 150 )
806815 )
807816 print ("--------------------" )
808817 print (f"Score: { score .mean ():.4f} " )
0 commit comments