Define metainfo and other parameters for all DMatrix interfaces. (#6601)
This PR ensures all DMatrix types have a common interface. * Fix logic in avoiding duplicated DMatrix in sklearn. * Check for consistency between DMatrix types. * Add doc for bounds.
This commit is contained in:
@@ -34,3 +34,25 @@ class TestDeviceQuantileDMatrix:
|
||||
import cupy as cp
|
||||
data = cp.random.randn(5, 5)
|
||||
xgb.DeviceQuantileDMatrix(data, cp.ones(5, dtype=np.float64))
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
def test_metainfo(self) -> None:
|
||||
import cupy as cp
|
||||
rng = cp.random.RandomState(1994)
|
||||
|
||||
rows = 10
|
||||
cols = 3
|
||||
data = rng.randn(rows, cols)
|
||||
|
||||
labels = rng.randn(rows)
|
||||
|
||||
fw = rng.randn(rows)
|
||||
fw -= fw.min()
|
||||
|
||||
m = xgb.DeviceQuantileDMatrix(data=data, label=labels, feature_weights=fw)
|
||||
|
||||
got_fw = m.get_float_info("feature_weights")
|
||||
got_labels = m.get_label()
|
||||
|
||||
cp.testing.assert_allclose(fw, got_fw)
|
||||
cp.testing.assert_allclose(labels, got_labels)
|
||||
|
||||
Reference in New Issue
Block a user