File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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 ))
You can’t perform that action at this time.
0 commit comments