Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82864ad

Browse files
committed
FIX avoid using sequences of sequences and fix tests
1 parent d2db017 commit 82864ad

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sklearn/tests/test_multiclass.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,20 @@ def test_ovr_always_present():
6363
# Note: tests is the case where _ConstantPredictor is utilised
6464
X = np.ones((10, 2))
6565
X[:5, :] = 0
66-
y = [[int(i >= 5), 2, 3] for i in range(10)]
66+
y = np.zeros((10, 3))
67+
y[5:, 0] = 1
68+
y[:, 1] = 1
69+
y[:, 2] = 1
70+
71+
[[int(i >= 5), 2, 3] for i in range(10)]
6772
ovr = OneVsRestClassifier(LogisticRegression())
6873
assert_warns(UserWarning, ovr.fit, X, y)
6974
y_pred = ovr.predict(X)
7075
assert_array_equal(np.array(y_pred), np.array(y))
7176
y_pred = ovr.decision_function(X)
7277
assert_equal(np.unique(y_pred[:, -2:]), 1)
7378
y_pred = ovr.predict_proba(X)
74-
assert_array_equal(y_pred[:, -2:], np.ones((X.shape[0], 2)))
79+
assert_array_equal(y_pred[:, -1], np.ones(X.shape[0]))
7580

7681
# y has a constantly absent label
7782
y = np.zeros((10, 2))

0 commit comments

Comments
 (0)