diff --git a/sknn/tests/test_classifier.py b/sknn/tests/test_classifier.py index de9be78..2a92ef5 100644 --- a/sknn/tests/test_classifier.py +++ b/sknn/tests/test_classifier.py @@ -45,10 +45,13 @@ def test_PredictUninitializedNoLabels(self): def test_PredictBinaryProbability(self): a_in = numpy.random.uniform(-1.0, 1.0, size=(8,16)) a_out = numpy.array((a_in.sum(axis=1) >= 0.0), dtype=numpy.int32) + a_out[0], a_out[-1] = 0, 1 self.nn.fit(a_in, a_out) a_proba = self.nn.predict_proba(a_in) + a_test = self.nn.predict(a_in) c_out = numpy.unique(a_out) + assert_equal(2, c_out.shape[0]) assert_equal(2, a_proba.shape[1]) diff --git a/sknn/tests/test_sklearn.py b/sknn/tests/test_sklearn.py index 9fcf105..27dd7b1 100644 --- a/sknn/tests/test_sklearn.py +++ b/sknn/tests/test_sklearn.py @@ -6,7 +6,8 @@ from sklearn.grid_search import GridSearchCV, RandomizedSearchCV from sklearn.cross_validation import cross_val_score - +from sklearn.ensemble import VotingClassifier + from sknn.mlp import Regressor as MLPR, Classifier as MLPC from sknn.mlp import Layer as L @@ -77,3 +78,12 @@ def test_Classifier(self): a_out = numpy.random.randint(0, 4, (64,)) cross_val_score(MLPC(layers=[L("Softmax")], n_iter=1), a_in, a_out, cv=5) + + +class TestVotingEnsemble(unittest.TestCase): + + def test_SingleVote(self): + a_in, a_out = numpy.random.uniform(0.0, 1.0, (64,16)), numpy.zeros((64,)) + vc = VotingClassifier([('nn1', MLPC(layers=[L("Softmax")], n_iter=1))]) + vc.fit(a_in, a_out) + vc.predict(a_in)