[dask] Fix ddqdm with empty partition. (#7510)

* Fix empty partition.

* war.
This commit is contained in:
Jiaming Yuan
2021-12-16 20:37:29 +08:00
committed by GitHub
parent a512b4b394
commit 70b12d898a
8 changed files with 59 additions and 35 deletions

View File

@@ -1071,7 +1071,7 @@ class DMatrix: # pylint: disable=too-many-instance-attributes
c_feature_types,
c_bst_ulong(len(feature_types))))
if len(feature_types) != self.num_col():
if len(feature_types) != self.num_col() and self.num_col() != 0:
msg = 'feature_types must have the same length as data'
raise ValueError(msg)
else:

View File

@@ -1015,6 +1015,8 @@ def _maybe_dataframe(
index = getattr(data, "index", None)
if lazy_isinstance(data, "cudf.core.dataframe", "DataFrame"):
import cudf
if prediction.size == 0:
return cudf.DataFrame({}, columns=columns, dtype=numpy.float32)
prediction = cudf.DataFrame(
prediction, columns=columns, dtype=numpy.float32, index=index