Exemplo n.º 1
0
 def test_only_accept_numpy_arrays(self):
     """Verifys ValueError exception is raised when a array is not
     provided"""
     with self.assertRaises(ValueError):
         ensembler = ensemble.BinaryEnsembler()
         ensembler.fit(1, targets)
     with self.assertRaises(ValueError):
         ensembler = ensemble.BinaryEnsembler()
         ensembler.fit(predictions, 1)
     with self.assertRaises(ValueError):
         ensembler = ensemble.BinaryEnsembler()
         ensembler.fit("example", targets)
     with self.assertRaises(ValueError):
         ensembler = ensemble.BinaryEnsembler()
         ensembler.fit(predictions, "example")
Exemplo n.º 2
0
 def test_rows_average_correctly(self):
     """Verifys that the sum of each row is correct when the mean
     method is used."""
     ensembler = ensemble.BinaryEnsembler(method="mean")
     ensembler.fit(predictions, targets)
     ensemble_ps = ensembler.predict(predictions)
     self.assertTrue(all(ensemble_ps == true_averages))
Exemplo n.º 3
0
 def test_warning_raised_if_no_weights_provided(self):
     """Verifys a warning is raised if weights are not provided but
     method=="weighted"."""
     with self.assertWarns(UserWarning):
         ensembler = ensemble.BinaryEnsembler(method="weighted")
         ensembler.fit(predictions, targets)
Exemplo n.º 4
0
 def test_weights_are_applied(self):
     """Verify correct ensembled predictions when weights applied."""
     ensembler = ensemble.BinaryEnsembler(method="weighted")
     ensembler.fit(predictions, targets, weights=ex_weights)
     ensemble_ps = ensembler.predict(predictions)
     self.assertTrue(all(ensemble_ps == weighted_average_predictions))
Exemplo n.º 5
0
 def test_preserves_number_of_rows(self):
     """Verifys that averaging is performed along the columnar axis."""
     ensembler = ensemble.BinaryEnsembler(method="mean")
     ensembler.fit(predictions, targets)
     ensemble_ps = ensembler.predict(predictions)
     self.assertTrue(ensemble_ps.shape[0] == predictions.shape[0])