@@ -166,22 +166,32 @@ def _check_fold_evaluations(self, fold_evaluations, num_repeats, num_folds, max_
166166 condition outside of this function. )
167167 default max_time_allowed (per fold, in milli seconds) = 1 minute, quite pessimistic
168168 '''
169- timing_measures = {'usercpu_time_millis_testing' , 'usercpu_time_millis_training' , 'usercpu_time_millis' }
169+
170+ # a dict mapping from openml measure to a tuple with the minimum and maximum allowed value
171+ check_measures = {'usercpu_time_millis_testing' : (0 , max_time_allowed ),
172+ 'usercpu_time_millis_training' : (0 , max_time_allowed ), # should take at least one millisecond (?)
173+ 'usercpu_time_millis' : (0 , max_time_allowed ),
174+ 'predictive_accuracy' : (0 , 1 )}
170175
171176 self .assertIsInstance (fold_evaluations , dict )
172177 if sys .version_info [:2 ] >= (3 , 3 ):
173- self .assertEquals (set (fold_evaluations .keys ()), timing_measures )
174- for measure in timing_measures :
178+ # this only holds if we are allowed to record time (otherwise some are missing)
179+ self .assertEquals (set (fold_evaluations .keys ()), set (check_measures .keys ()))
180+
181+ for measure in check_measures .keys ():
182+ if measure in fold_evaluations :
175183 num_rep_entrees = len (fold_evaluations [measure ])
176184 self .assertEquals (num_rep_entrees , num_repeats )
185+ min_val = check_measures [measure ][0 ]
186+ max_val = check_measures [measure ][1 ]
177187 for rep in range (num_rep_entrees ):
178188 num_fold_entrees = len (fold_evaluations [measure ][rep ])
179189 self .assertEquals (num_fold_entrees , num_folds )
180190 for fold in range (num_fold_entrees ):
181191 evaluation = fold_evaluations [measure ][rep ][fold ]
182192 self .assertIsInstance (evaluation , float )
183- self .assertGreater (evaluation , 0 ) # should take at least one millisecond (? )
184- self .assertLess (evaluation , max_time_allowed )
193+ self .assertGreaterEqual (evaluation , min_val )
194+ self .assertLessEqual (evaluation , max_val )
185195
186196
187197 def _check_sample_evaluations (self , sample_evaluations , num_repeats , num_folds , num_samples , max_time_allowed = 60000 ):
@@ -193,12 +203,20 @@ def _check_sample_evaluations(self, sample_evaluations, num_repeats, num_folds,
193203 condition outside of this function. )
194204 default max_time_allowed (per fold, in milli seconds) = 1 minute, quite pessimistic
195205 '''
196- timing_measures = {'usercpu_time_millis_testing' , 'usercpu_time_millis_training' , 'usercpu_time_millis' }
206+
207+ # a dict mapping from openml measure to a tuple with the minimum and maximum allowed value
208+ check_measures = {'usercpu_time_millis_testing' : (0 , max_time_allowed ),
209+ 'usercpu_time_millis_training' : (0 , max_time_allowed ), # should take at least one millisecond (?)
210+ 'usercpu_time_millis' : (0 , max_time_allowed ),
211+ 'predictive_accuracy' : (0 , 1 )}
197212
198213 self .assertIsInstance (sample_evaluations , dict )
199214 if sys .version_info [:2 ] >= (3 , 3 ):
200- self .assertEquals (set (sample_evaluations .keys ()), timing_measures )
201- for measure in timing_measures :
215+ # this only holds if we are allowed to record time (otherwise some are missing)
216+ self .assertEquals (set (sample_evaluations .keys ()), set (check_measures .keys ()))
217+
218+ for measure in check_measures .keys ():
219+ if measure in sample_evaluations :
202220 num_rep_entrees = len (sample_evaluations [measure ])
203221 self .assertEquals (num_rep_entrees , num_repeats )
204222 for rep in range (num_rep_entrees ):
0 commit comments