Skip to content

Commit

Permalink
try another way
Browse files Browse the repository at this point in the history
  • Loading branch information
qinhanmin2014 committed Sep 19, 2017
1 parent ab3ed4f commit 6b2cf79
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sklearn/metrics/tests/test_common.py
Expand Up @@ -943,7 +943,7 @@ def test_averaging_multilabel_all_ones():

@ignore_warnings
def check_sample_weight_invariance(name, metric, y1, y2):
rng = np.random.RandomState(0)
rng = np.random.RandomState(10)
sample_weight = rng.randint(1, 10, size=len(y1))

# check that unit weights gives the same score as no weight
Expand Down Expand Up @@ -999,10 +999,9 @@ def check_sample_weight_invariance(name, metric, y1, y2):
# check that the score is invariant under scaling of the weights by a
# common factor
for scaling in [2, 0.3]:
np.testing.assert_allclose(
assert_almost_equal(
weighted_score,
metric(y1, y2, sample_weight=sample_weight * scaling),
atol=1e-2,
err_msg="%s sample_weight is not invariant "
"under scaling" % name)

Expand All @@ -1027,7 +1026,7 @@ def test_sample_weight_invariance(n_samples=50):
metric, y_true, y_pred

# binary
random_state = check_random_state(0)
random_state = check_random_state(10)
y_true = random_state.randint(0, 2, size=(n_samples, ))
y_pred = random_state.randint(0, 2, size=(n_samples, ))
y_score = random_state.random_sample(size=(n_samples,))
Expand Down

0 comments on commit 6b2cf79

Please sign in to comment.