Example #1
0
    def _generate_inner_folds(self):

        self.inner_folds = FoldInfo.generate_folds(self.cross_validaton_info.inner_cv,
                                                   self._validation_X,
                                                   self._validation_y,
                                                   self._validation_kwargs)

        self.cross_validaton_info.inner_folds[self.outer_fold_id] = {f.fold_id: f for f in self.inner_folds}
Example #2
0
 def test_no_cv_strategy_eval_final_performance_false(self):
     test_size = 0.15
     fold_list = FoldInfo.generate_folds(None,
                                         self.X,
                                         self.y,
                                         self.kwargs,
                                         eval_final_performance=False,
                                         test_size=test_size)
     # check that we have only one outer fold, that is split in training and test according to test size
     self.assertEqual(len(fold_list), 1)
     self.assertEqual(len(fold_list[0].train_indices), self.num_subjects)
     self.assertEqual(len(fold_list[0].test_indices), 0)
Example #3
0
 def base_assertions(self, cv, nr_of_folds, eval_final_performance=True):
     fold_list = FoldInfo.generate_folds(
         cv,
         self.X,
         self.y,
         self.kwargs,
         eval_final_performance=eval_final_performance)
     self.assertTrue(len(fold_list) == nr_of_folds)
     for generated_fold in fold_list:
         self.assertEqual(len(generated_fold.train_indices),
                          (nr_of_folds - 1) *
                          (self.num_subjects / nr_of_folds))
         self.assertEqual(len(generated_fold.test_indices),
                          (self.num_subjects / nr_of_folds))
     # we always start with 1 for the investigator
     self.assertEqual(fold_list[0].fold_nr, 1)
     return fold_list