def test_fit(self): bag_params = {'model_params': {'ind': 0}, 'n_models_fit': 10, 'seed': 23} bag = ens.BaggingBinaryClassifier(SimpleClassifier, **bag_params) bag.fit(self.X, self.Y) assert bag.params == bag_params assert bag.n_models == bag_params['n_models_fit'] == bag.n_models_fit
def test_oob_error_unused_obs(self): bag = ens.BaggingBinaryClassifier(SimpleClassifier, seed=25, n_models_fit=1) with warnings.catch_warnings(record=True) as w: bag.fit(self.X, self.Y) assert len(w) == 0
def test_init1(self): model_params = {'a': 5, 'b': True} bag_params = {'model_params': model_params, 'n_models_fit': 5, 'seed': 23} bag = ens.BaggingBinaryClassifier(ExBinaryClassifier1, model_params=model_params, n_models_fit=5, seed=23) bag.params == bag_params
def test_classify_easy(self): bag_params = {'model_params': {'ind': 1}, 'n_models_fit': 10, 'seed': 23} bag = ens.BaggingBinaryClassifier(SimpleClassifier, **bag_params) bag.fit(self.X, self.Y) assert np.all(bag.classify(self.X) == self.Y)
def test_oob_error(self): bag = ens.BaggingBinaryClassifier(SimpleClassifier, seed=25) bag.fit(self.X, self.Y) assert np.isfinite(bag.oob_error) assert 0. <= bag.oob_error <= 1.
def test_fit_verbose(self): bag_params = {'model_params': {'ind': 0}, 'n_models_fit': 10, 'seed': 23} bag = ens.BaggingBinaryClassifier(SimpleClassifier, **bag_params) bag.fit(self.X, self.Y, verbose=True)
def test_fit_param(self): bag = ens.BaggingBinaryClassifier(SimpleClassifier) bag.fit(self.X, self.Y, fit_params={'param': 2})
def test_fit_oob_noerror(self): bag = ens.BaggingBinaryClassifier(NotBinaryClassifier) bag.fit(self.X, self.Y)
def test_oob_nofit(self): bag = ens.BaggingBinaryClassifier(ExBinaryClassifier1) bag.oob_error
def test_init2(self): bag_params = {'model_params': {}, 'n_models_fit': 5, 'seed': None} bag = ens.BaggingBinaryClassifier(ExBinaryClassifier1, n_models_fit=5) bag.params == bag_params