def test_basic_cv(self): c = self.make_config() n_folds = random.randint(2,10) repeat = 2 scores = models.cv(self.ds, c, n_folds, repeat) self.assertAlmostEqual(scores.mean(), 0) self.assertEqual(len(scores), n_folds*repeat)
def test_basic_cv_bad_valid(self): # shouldnt matter c = self.make_config(target='2a_plus_b_valid_diff') n_folds = random.randint(2,10) repeat = 2 scores = models.cv(self.ds, c, n_folds, repeat) self.assertAlmostEqual(scores.mean(), 0) self.assertEqual(len(scores), n_folds*repeat)
def test_basic_cv_no_relationship(self): c = self.make_config(features=[ 'c' ]) n_folds = random.randint(2,10) repeat = 2 scores = models.cv(self.ds, c, n_folds, repeat) self.assertTrue(3 < scores.mean() < 6) self.assertEqual(len(scores), n_folds*repeat)
def test_blending(self): pcnf = Configuration( target='b', features=[ '2a_plus_b_valid_diff', 'a'], model= TestPredictor(linear_model.LinearRegression()) ) c = self.make_config( target='b', features=[ Predictions(pcnf) ]) scores = models.cv(self.ds, c) self.assertEqual(pcnf.model.n_fit, 5) print scores self.assertTrue( 3 < scores.mean() < 5)