Beispiel #1
0
 def test_predict_sparse(self):
     sparse_data = self.housing.to_sparse()
     booster = CatGBRegressor()
     model = booster(sparse_data)
     pred = model(sparse_data)
     self.assertEqual(pred.shape, (len(sparse_data),))
     self.assertGreater(all(pred), 0)
Beispiel #2
0
 def test_set_params(self):
     booster = CatGBRegressor(n_estimators=42, max_depth=4)
     self.assertEqual(booster.params["n_estimators"], 42)
     self.assertEqual(booster.params["max_depth"], 4)
     model = booster(self.housing)
     params = model.cat_model.get_params()
     self.assertEqual(params["n_estimators"], 42)
     self.assertEqual(params["max_depth"], 4)
 def test_default_parameters_reg(self):
     data = Table("housing")
     booster = CatGBRegressor()
     model = booster(data)
     params = model.cat_model.get_all_params()
     self.assertEqual(self.editor.n_estimators, 100)
     self.assertEqual(params["iterations"], 1000)
     self.assertEqual(params["depth"], self.editor.max_depth)
     self.assertEqual(params["l2_leaf_reg"], self.editor.lambda_)
     self.assertEqual(params["rsm"], self.editor.colsample_bylevel)
     self.assertEqual(self.editor.learning_rate, 0.3)
Beispiel #4
0
 def test_scorer(self):
     booster = CatGBRegressor()
     self.assertIsInstance(booster, Scorer)
     booster.score(self.housing)
Beispiel #5
0
 def test_predict_numpy(self):
     booster = CatGBRegressor()
     model = booster(self.housing)
     pred = model(self.housing.X)
     self.assertEqual(pred.shape, (len(self.housing),))
     self.assertGreater(all(pred), 0)
Beispiel #6
0
 def test_predict_single_instance(self):
     booster = CatGBRegressor()
     model = booster(self.housing)
     for ins in self.housing:
         pred = model(ins)
         self.assertGreater(pred, 0)
Beispiel #7
0
 def test_GBTrees(self):
     booster = CatGBRegressor()
     cv = CrossValidation(k=10)
     results = cv(self.housing, [booster])
     RMSE(results)