Пример #1
0
 def test_adaboost_reg_base_estimator(self):
     np.random.seed(0)
     stump_estimator = TreeRegressionLearner(max_depth=1)
     tree_estimator = TreeRegressionLearner()
     stump = SklAdaBoostRegressionLearner(base_estimator=stump_estimator)
     tree = SklAdaBoostRegressionLearner(base_estimator=tree_estimator)
     results = CrossValidation(self.housing, [stump, tree], k=3)
     rmse = RMSE(results)
     self.assertGreaterEqual(rmse[0], rmse[1])
Пример #2
0
 def test_predict_numpy_reg(self):
     learn = SklAdaBoostRegressionLearner()
     m = learn(self.housing)
     pred = m(self.housing.X)
     self.assertEqual(len(self.housing), len(pred))
     self.assertGreater(all(pred), 0)
Пример #3
0
 def test_predict_single_instance_reg(self):
     learn = SklAdaBoostRegressionLearner()
     m = learn(self.housing)
     ins = self.housing[0]
     pred = m(ins)
     self.assertGreaterEqual(pred, 0)
Пример #4
0
 def test_adaboost_reg(self):
     learn = SklAdaBoostRegressionLearner()
     cv = CrossValidation(k=3)
     results = cv(self.housing, [learn])
     _ = RMSE(results)
Пример #5
0
 def test_adaboost_adequacy_reg(self):
     learner = SklAdaBoostRegressionLearner()
     self.assertRaises(ValueError, learner, self.iris)
Пример #6
0
 def test_predict_table_reg(self):
     learn = SklAdaBoostRegressionLearner()
     m = learn(self.housing)
     pred = m(self.housing)
     self.assertEqual(len(self.housing), len(pred))
     self.assertTrue(all(pred) > 0)
Пример #7
0
 def test_predict_single_instance_reg(self):
     learn = SklAdaBoostRegressionLearner()
     m = learn(self.housing)
     for ins in self.housing:
         pred = m(ins)
         self.assertTrue(pred > 0)
Пример #8
0
 def test_adaboost_reg(self):
     learn = SklAdaBoostRegressionLearner()
     results = CrossValidation(self.housing, [learn], k=10)
     _ = RMSE(results)