Skip to content

Commit

Permalink
add regression test for #6273
Browse files Browse the repository at this point in the history
  • Loading branch information
morokosi committed Mar 31, 2024
1 parent 64006b1 commit 75ba6eb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/python_package_test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,16 @@ def test_dataset_construction_overwrites_user_provided_metadata_fields():
np_assert_array_equal(dtrain.get_field("weight"), expected_weight, strict=True)


def test_dataset_construction_with_high_cardinality_categorical_succeeds():
pd = pytest.importorskip("pandas")
X = pd.DataFrame({"x1": np.random.randint(0, 5_000, 10_000)})
y = np.random.rand(10_000)
ds = lgb.Dataset(X, y, categorical_feature=["x1"])
ds.construct()
assert ds.num_data() == 10_000
assert ds.num_feature() == 1


def test_choose_param_value():
original_params = {
"local_listen_port": 1234,
Expand Down Expand Up @@ -877,3 +887,4 @@ def test_feature_names_are_set_correctly_when_no_feature_names_passed_into_Datas
data=np.random.randn(100, 3),
)
assert ds.construct().feature_name == ["Column_0", "Column_1", "Column_2"]

0 comments on commit 75ba6eb

Please sign in to comment.