Skip to content

Commit

Permalink
Merge pull request scikit-learn#6371 from yenchenlin1994/add-test-for…
Browse files Browse the repository at this point in the history
…-vote-classifier

[MRG+1] Add test for voting classifier‘s init errors
  • Loading branch information
TomDLT committed Feb 29, 2016
2 parents 68de3b2 + e2e773d commit 1049642
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sklearn/ensemble/tests/test_voting_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ def test_estimator_init():
' a list of (string, estimator) tuples')
assert_raise_message(AttributeError, msg, eclf.fit, X, y)

clf = LogisticRegression(random_state=1)

eclf = VotingClassifier(estimators=[('lr', clf)], voting='error')
msg = ('Voting must be \'soft\' or \'hard\'; got (voting=\'error\')')
assert_raise_message(ValueError, msg, eclf.fit, X, y)

eclf = VotingClassifier(estimators=[('lr', clf)], weights=[1, 2])
msg = ('Number of classifiers and weights must be equal'
'; got 2 weights, 1 estimators')
assert_raise_message(ValueError, msg, eclf.fit, X, y)


def test_predictproba_hardvoting():
eclf = VotingClassifier(estimators=[('lr1', LogisticRegression()),
Expand Down

0 comments on commit 1049642

Please sign in to comment.