Skip to content
This repository was archived by the owner on Jul 10, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sknn/tests/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
12 changes: 11 additions & 1 deletion sknn/tests/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)