Skip to content

Commit

Permalink
n_samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 16, 2021
1 parent 0f4d87c commit 6536cd9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
16 changes: 10 additions & 6 deletions tests/python-gpu/test_gpu_eval_metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import xgboost
import pytest

sys.path.append("tests/python")
import test_eval_metrics as test_em # noqa
Expand All @@ -8,17 +9,20 @@
class TestGPUEvalMetrics:
cpu_test = test_em.TestEvalMetrics()

def test_roc_auc_binary(self):
self.cpu_test.run_roc_auc_binary("gpu_hist")
@pytest.mark.parametrize("n_samples", [4, 100, 1000])
def test_roc_auc_binary(self, n_samples):
self.cpu_test.run_roc_auc_binary("gpu_hist", n_samples)

def test_roc_auc_multi(self):
self.cpu_test.run_roc_auc_multi("gpu_hist")
@pytest.mark.parametrize("n_samples", [4, 100, 1000])
def test_roc_auc_multi(self, n_samples):
self.cpu_test.run_roc_auc_multi("gpu_hist", n_samples)

def test_roc_auc_ltr(self):
@pytest.mark.parametrize("n_samples", [4, 100, 1000])
def test_roc_auc_ltr(self, n_samples):
import numpy as np

rng = np.random.RandomState(1994)
n_samples = 100
n_samples = n_samples
n_features = 10
X = rng.randn(n_samples, n_features)
y = rng.randint(0, 16, size=n_samples)
Expand Down
18 changes: 10 additions & 8 deletions tests/python/test_eval_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def test_eval_metrics(self):
assert gbdt_01.predict(dvalid)[0] == gbdt_03.predict(dvalid)[0]
assert gbdt_03.predict(dvalid)[0] != gbdt_04.predict(dvalid)[0]

def run_roc_auc_binary(self, tree_method):
def run_roc_auc_binary(self, tree_method, n_samples):
import numpy as np
from sklearn.datasets import make_classification
from sklearn.metrics import roc_auc_score

rng = np.random.RandomState(1994)
n_samples = 1000
n_samples = n_samples
n_features = 10

X, y = make_classification(
Expand Down Expand Up @@ -142,16 +142,17 @@ def run_roc_auc_binary(self, tree_method):
np.testing.assert_allclose(skl_auc, auc, rtol=1e-6)

@pytest.mark.skipif(**tm.no_sklearn())
def test_roc_auc(self):
self.run_roc_auc_binary("hist")
@pytest.mark.parametrize("n_samples", [4, 100, 1000])
def test_roc_auc(self, n_samples):
self.run_roc_auc_binary("hist", n_samples)

def run_roc_auc_multi(self, tree_method):
def run_roc_auc_multi(self, tree_method, n_samples):
import numpy as np
from sklearn.datasets import make_classification
from sklearn.metrics import roc_auc_score

rng = np.random.RandomState(1994)
n_samples = 1000
n_samples = n_samples
n_features = 10
n_classes = 4

Expand Down Expand Up @@ -186,5 +187,6 @@ def run_roc_auc_multi(self, tree_method):
auc = float(booster.eval(xgb.DMatrix(X, y)).split(":")[1])
np.testing.assert_allclose(skl_auc, auc, rtol=1e-6)

def test_roc_auc_multi(self):
self.run_roc_auc_multi("hist")
@pytest.mark.parametrize("n_samples", [4, 100, 1000])
def test_roc_auc_multi(self, n_samples):
self.run_roc_auc_multi("hist", n_samples)

0 comments on commit 6536cd9

Please sign in to comment.