@@ -259,15 +259,15 @@ def _evaluate(
259259 emissions_data .emissions if emissions_data else np .nan
260260 )
261261
262- _ensure_fitted (cvclf )
263-
264262 if self .hdf5_path is not None and self .save_model :
265263 _save_model_cv (
266264 model = cvclf ,
267265 save_path = model_save_path ,
268266 cv_index = cv_ind ,
269267 )
270268
269+ _ensure_fitted (cvclf )
270+
271271 score = scorer (cvclf , X_ [test ], y_ [test ])
272272 acc .append (score )
273273
@@ -612,15 +612,15 @@ def evaluate(
612612 emissions_data = tracker .stop_task ()
613613 emissions = emissions_data .emissions if emissions_data else np .nan
614614
615- _ensure_fitted (cvclf )
616-
617615 if self .hdf5_path is not None and self .save_model :
618616 _save_model_cv (
619617 model = cvclf ,
620618 save_path = model_save_path ,
621619 cv_index = str (cv_ind ),
622620 )
623621
622+ _ensure_fitted (cvclf )
623+
624624 model_list .append (cvclf )
625625 score = scorer (cvclf , X [test ], y [test ])
626626
@@ -810,8 +810,6 @@ def evaluate(
810810 emissions_data = tracker .stop_task ()
811811 emissions = emissions_data .emissions if emissions_data else np .nan
812812
813- _ensure_fitted (cvclf )
814-
815813 if self .hdf5_path is not None and self .save_model :
816814 model_save_path = _create_save_path (
817815 hdf5_path = self .hdf5_path ,
@@ -826,6 +824,8 @@ def evaluate(
826824 model = cvclf , save_path = model_save_path , cv_index = str (cv_ind )
827825 )
828826
827+ _ensure_fitted (cvclf )
828+
829829 # we eval on each session
830830 for session in np .unique (sessions [test ]):
831831 ix = sessions [test ] == session
0 commit comments