Skip to content

Commit

Permalink
MAINT: catch internal random_state warnings (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb authored Oct 10, 2020
1 parent 282adf0 commit 6b3dd47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ def test_sample_weights_all_zero():
"""
# build estimator
estimator = KerasClassifier(
build_fn=dynamic_classifier,
model__hidden_layer_sizes=(100,),
epochs=10,
random_state=0,
build_fn=dynamic_classifier, model__hidden_layer_sizes=(100,),
)

# we create 20 points
Expand Down
6 changes: 4 additions & 2 deletions tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ def test_sample_weights_fit():
# heavily weight towards y=1 points
sw_first_class = [0.8] * 5000 + [0.2] * 5000
# train estimator 1 with weights
estimator1.fit(X, y, sample_weight=sw_first_class)
with pytest.warns(UserWarning, match="Setting the random state"):
estimator1.fit(X, y, sample_weight=sw_first_class)
# train estimator 2 without weights
estimator2.fit(X, y)
with pytest.warns(UserWarning, match="Setting the random state"):
estimator2.fit(X, y)
# estimator1 should tilt towards y=1
# estimator2 should predict about equally
average_diff_pred_prob_1 = np.average(np.diff(estimator1.predict_proba(X), axis=1))
Expand Down

0 comments on commit 6b3dd47

Please sign in to comment.