Categorical data support for cuDF. (#7042)

* Add support in DMatrix.
* Add support in DQM, except for iterator.
This commit is contained in:
Jiaming Yuan
2021-06-17 13:54:33 +08:00
committed by GitHub
parent 5c2d7a18c9
commit d9799b09d0
5 changed files with 129 additions and 106 deletions

View File

@@ -171,6 +171,21 @@ Arrow specification.'''
def test_cudf_metainfo_device_dmatrix(self):
_test_cudf_metainfo(xgb.DeviceQuantileDMatrix)
@pytest.mark.skipif(**tm.no_cudf())
def test_categorical(self):
import cudf
_X, _y = tm.make_categorical(100, 30, 17, False)
X = cudf.from_pandas(_X)
y = cudf.from_pandas(_y)
Xy = xgb.DMatrix(X, y, enable_categorical=True)
assert len(Xy.feature_types) == X.shape[1]
assert all(t == "categorical" for t in Xy.feature_types)
Xy = xgb.DeviceQuantileDMatrix(X, y, enable_categorical=True)
assert len(Xy.feature_types) == X.shape[1]
assert all(t == "categorical" for t in Xy.feature_types)
@pytest.mark.skipif(**tm.no_cudf())
@pytest.mark.skipif(**tm.no_cupy())