Make test for categorical data deterministic. (#8080)
This commit is contained in:
parent
dae7a41baa
commit
647d3844dd
@ -87,6 +87,7 @@ class TestGPUUpdaters:
|
||||
def test_categorical_missing(self, rows, cols, cats):
|
||||
self.cputest.run_categorical_missing(rows, cols, cats, "gpu_hist")
|
||||
|
||||
@pytest.mark.skipif(**tm.no_pandas())
|
||||
def test_max_cat(self) -> None:
|
||||
self.cputest.run_max_cat("gpu_hist")
|
||||
|
||||
|
||||
@ -205,10 +205,13 @@ class TestTreeMethod:
|
||||
def run_max_cat(self, tree_method: str) -> None:
|
||||
"""Test data with size smaller than number of categories."""
|
||||
import pandas as pd
|
||||
|
||||
rng = np.random.default_rng(0)
|
||||
n_cat = 100
|
||||
n = 5
|
||||
|
||||
X = pd.Series(
|
||||
["".join(choice(ascii_lowercase) for i in range(3)) for i in range(n_cat)],
|
||||
["".join(rng.choice(list(ascii_lowercase), size=3)) for i in range(n_cat)],
|
||||
dtype="category",
|
||||
)[:n].to_frame()
|
||||
|
||||
@ -222,6 +225,7 @@ class TestTreeMethod:
|
||||
assert tm.non_increasing(reg.evals_result()["validation_0"]["rmse"])
|
||||
|
||||
@pytest.mark.parametrize("tree_method", ["hist", "approx"])
|
||||
@pytest.mark.skipif(**tm.no_pandas())
|
||||
def test_max_cat(self, tree_method) -> None:
|
||||
self.run_max_cat(tree_method)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user