@@ -46,11 +46,9 @@ def evaluate(self, teamsvecs, splits, on_train=False, per_epoch=False, per_insta
46
46
47
47
predfiles = [f'{ self .output } /f{ foldidx } .{ pred_set } .pred' ] #the first file as a hook
48
48
if per_epoch : predfiles += [f'{ self .output } /{ _ } ' for _ in os .listdir (self .output ) if re .match (f'f{ foldidx } .{ pred_set } .e\d+.pred$' , _ )]
49
- for i , predfile in enumerate (sorted (sorted (predfiles ), key = len )):
50
- epoch = f'e{ i - 1 } .' if i > 0 else '' #the first file is non-epoch-based but the rest are
51
- filename = f'{ self .output } /f{ foldidx } .{ pred_set } .{ epoch } '
52
- Y_ = Ntf .torch .load (f'{ filename } pred' )['y_pred' ]
53
- log .info (f'Evaluating predictions at { filename } pred ... for { metrics } ' )
49
+ for i , predfile in enumerate (sorted (sorted (predfiles ), key = len )): #the first file is/should be non-epoch-based
50
+ Y_ = Ntf .torch .load (predfile )['y_pred' ]
51
+ log .info (f'Evaluating predictions at { predfile } ... for { metrics } ' )
54
52
55
53
log .info (f'{ metrics .trec } ...' )
56
54
df , df_mean = metric .calculate_metrics (Y , Y_ , per_instance , metrics )
@@ -59,7 +57,7 @@ def evaluate(self, teamsvecs, splits, on_train=False, per_epoch=False, per_insta
59
57
log .info ("['aucroc'] and curve values (fpr, tpr) ..." )
60
58
aucroc , fpr_tpr = metric .calculate_auc_roc (Y , Y_ )
61
59
df_mean .loc ['aucroc' ] = aucroc
62
- with open (f'{ filename } pred .eval.roc.pkl' , 'wb' ) as outfile : pickle .dump (fpr_tpr , outfile )
60
+ with open (f'{ predfile } .eval.roc.pkl' , 'wb' ) as outfile : pickle .dump (fpr_tpr , outfile )
63
61
64
62
if (m := [m for m in metrics .other if 'skill_coverage' in m ]): #since this metric comes with topks str like 'skill_coverage_2,5,10'
65
63
log .info (f'{ m } ...' )
@@ -70,9 +68,9 @@ def evaluate(self, teamsvecs, splits, on_train=False, per_epoch=False, per_insta
70
68
df = pd .concat ([df , df_skc ], axis = 0 )
71
69
df_mean = pd .concat ([df_mean , df_mean_skc ], axis = 0 )
72
70
73
- if per_instance : df .to_csv (f'{ filename } pred .eval.per_instance.csv' , float_format = '%.5f' )
74
- log .info (f'Saving file per fold as { filename } pred .eval.mean.csv' )
75
- df_mean .to_csv (f'{ filename } pred .eval.mean.csv' )
71
+ if per_instance : df .to_csv (f'{ predfile } .eval.per_instance.csv' , float_format = '%.5f' )
72
+ log .info (f'Saving file per fold as { predfile } .eval.mean.csv' )
73
+ df_mean .to_csv (f'{ predfile } .eval.mean.csv' )
76
74
if i == 0 : # non-epoch-based only, as there is different number of epochs for each fold model due to earlystopping
77
75
fold_mean = pd .concat ([fold_mean , df_mean ], axis = 1 )
78
76
if per_instance : fold_mean_per_instance = fold_mean_per_instance .add (df , fill_value = 0 )
0 commit comments