Skip to content

Commit

Permalink
Fix a failing test with sklearn 0.21.2
Browse files Browse the repository at this point in the history
The test relied upon 75 samples being split into 60/15 for the
internal train/valid split. However, with certain sklearn versions,
the split would be 59/16 because of stratification. As a solution, the
target values are all set to 0. Since they are not important for the
tests, this solution works.
  • Loading branch information
BenjaminBossan committed Apr 11, 2020
1 parent c12f40b commit b4c2e8a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion skorch/tests/callbacks/test_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,10 @@ def net(self, classifier_module, train_loss, valid_loss, classifier_data):
n = 75
# n=75 with a 4/5 train/valid split -> 60/15 samples; with a
# batch size of 10, that leads to train batch sizes of
# [10,10,10,10] and valid batich sizes of [10,5]
# [10,10,10,10] and valid batch sizes of [10,5]; all labels
# are set to 0 to ensure that the stratified split is exactly
# equal to the desired split
y = np.zeros_like(y)
return net.fit(X[:n], y[:n])

@pytest.fixture
Expand Down

0 comments on commit b4c2e8a

Please sign in to comment.