Skip to content

Commit

Permalink
Doc: better tests for logistic.
Browse files Browse the repository at this point in the history
Reverse order of classes after sugestion Methieu Blondel, this way we
also check that predict_proba does the right sorting for each class.

Also removed obsolete tests.
  • Loading branch information
Fabian Pedregosa committed Oct 22, 2010
1 parent b6f14db commit 1ac91af
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scikits/learn/glm/sparse/tests/test_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

X = [[-1, 0], [0, 1], [1, 1]]
Y1 = [0, 1, 1]
Y2 = [0, 1, 2]
Y2 = [2, 1, 0]
iris = datasets.load_iris()

def test_predict_2_classes():
Expand Down
15 changes: 1 addition & 14 deletions scikits/learn/glm/tests/test_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

X = [[-1, 0], [0, 1], [1, 1]]
Y1 = [0, 1, 1]
Y2 = [0, 1, 2]
Y2 = [2, 1, 0]
iris = datasets.load_iris()

def test_predict_2_classes():
Expand Down Expand Up @@ -54,19 +54,6 @@ def test_predict_iris():
pred = clf.predict_proba(iris.data).argmax(axis=1)
assert np.mean(pred == iris.target) > .95

def test_predict_proba():
"""
I think this test is wrong. Is there a way to know the right results ?
"""
raise nose.SkipTest("XFailed test")
clf = logistic.LogisticRegression().fit(X, Y2)
assert_array_almost_equal(clf.predict_proba([[1, 1]]),
[[ 0.21490268, 0.32639437, 0.45870294]])

clf = logistic.LogisticRegression(penalty='l1').fit(X, Y2)
assert_array_almost_equal(clf.predict_proba([[2, 2]]),
[[ 0.33333333, 0.33333333, 0.33333333]])


if __name__ == '__main__':
import nose
Expand Down

0 comments on commit 1ac91af

Please sign in to comment.