Skip to content

Commit cebb7da

Browse files
glouppelarsmans
authored andcommitted
TST: test_base in sklearn.ensemble
1 parent cc74076 commit cebb7da

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Testing for the base module (sklearn.ensemble.base).
3+
"""
4+
5+
# Authors: Gilles Louppe
6+
# License: BSD 3 clause
7+
8+
from numpy.testing import assert_equal
9+
from nose.tools import assert_raises, assert_true
10+
11+
from sklearn.datasets import load_iris
12+
from sklearn.ensemble import BaggingClassifier
13+
from sklearn.linear_model import Perceptron
14+
15+
16+
def test_base():
17+
"""Check BaseEnsemble methods."""
18+
ensemble = BaggingClassifier(base_estimator=Perceptron(), n_estimators=3)
19+
20+
iris = load_iris()
21+
ensemble.fit(iris.data, iris.target)
22+
ensemble.estimators_ = [] # empty the list and create estimators manually
23+
24+
ensemble._make_estimator()
25+
ensemble._make_estimator()
26+
ensemble._make_estimator()
27+
ensemble._make_estimator(append=False)
28+
29+
assert_equal(3, len(ensemble))
30+
assert_equal(3, len(ensemble.estimators_))
31+
32+
assert_true(isinstance(ensemble[0], Perceptron))

0 commit comments

Comments
 (0)