8000 TST use global_random_seed in sklearn/metrics/tests/test_classificati… · scikit-learn/scikit-learn@0a39bb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a39bb5

Browse files
authored
TST use global_random_seed in sklearn/metrics/tests/test_classification.py (#30851)
1 parent 9ce8be6 commit 0a39bb5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

sklearn/metrics/tests/test_classification.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ def test_zero_division_nan_warning(metric, y_true, y_pred):
970970
assert result == 0.0
971971

972972

973-
def test_matthews_corrcoef_against_numpy_corrcoef():
974-
rng = np.random.RandomState(0)
973+
def test_matthews_corrcoef_against_numpy_corrcoef(global_random_seed):
974+
rng = np.random.RandomState(global_random_seed)
975975
y_true = rng.randint(0, 2, size=20)
976976
y_pred = rng.randint(0, 2, size=20)
977977

@@ -980,11 +980,11 @@ def test_matthews_corrcoef_against_numpy_corrcoef():
980980
)
981981

982982

983-
def test_matthews_corrcoef_against_jurman():
983+
def test_matthews_corrcoef_against_jurman(global_random_seed):
984984
# Check that the multiclass matthews_corrcoef agrees with the definition
985985
# presented in Jurman, Riccadonna, Furlanello, (2012). A Comparison of MCC
986986
# and CEN Error Measures in MultiClass Prediction
987-
rng = np.random.RandomState(0)
987+
rng = np.random.RandomState(global_random_seed)
988988
y_true = rng.randint(0, 2, size=20)
989989
y_pred = rng.randint(0, 2, size=20)
990990
sample_weight = rng.rand(20)
@@ -1019,8 +1019,8 @@ def test_matthews_corrcoef_against_jurman():
10191019
assert_almost_equal(mcc_ours, mcc_jurman, 10)
10201020

10211021

1022-
def test_matthews_corrcoef():
1023-
rng = np.random.RandomState(0)
1022+
def test_matthews_corrcoef(global_random_seed):
1023+
rng = np.random.RandomState(global_random_seed)
10241024
y_true = ["a" if i == 0 else "b" for i in rng.randint(0, 2, size=20)]
10251025

10261026
# corrcoef of same vectors must be 1
@@ -1054,8 +1054,8 @@ def test_matthews_corrcoef():
10541054
assert_almost_equal(matthews_corrcoef(y_1, y_2, sample_weight=mask), 0.0)
10551055

10561056

1057-
def test_matthews_corrcoef_multiclass():
1058-
rng = np.random.RandomState(0)
1057+
def test_matthews_corrcoef_multiclass(global_random_seed):
1058+
rng = np.random.RandomState(global_random_seed)
10591059
ord_a = ord("a")
10601060
n_classes = 4
10611061
y_true = [chr(ord_a + i) for i in rng.randint(0, n_classes, size=20)]
@@ -1111,9 +1111,9 @@ def test_matthews_corrcoef_multiclass():
11111111

11121112

11131113
@pytest.mark.parametrize("n_points", [100, 10000])
1114-
def test_matthews_corrcoef_overflow(n_points):
1114+
def test_matthews_corrcoef_overflow(n_points, global_random_seed):
11151115
# https://github.com/scikit-learn/scikit-learn/issues/9622
1116-
rng = np.random.RandomState(20170906)
1116+
rng = np.random.RandomState(global_random_seed)
11171117

11181118
def mcc_safe(y_true, y_pred):
11191119
conf_matrix = confusion_matrix(y_true, y_pred)

0 commit comments

Comments
 (0)
0