diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 5e1a309e04da..7864d541f49d 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -197,6 +197,7 @@ def _from_numpy_array( nthread: int, feature_names: Optional[FeatureNames], feature_types: Optional[FeatureTypes], + data_split_mode: DataSplitMode = DataSplitMode.ROW, ) -> DispatchedDataBackendReturnType: """Initialize data from a 2-D numpy matrix.""" _check_data_shape(data) @@ -205,7 +206,11 @@ def _from_numpy_array( _check_call( _LIB.XGDMatrixCreateFromDense( _array_interface(data), - make_jcargs(missing=float(missing), nthread=int(nthread)), + make_jcargs( + missing=float(missing), + nthread=int(nthread), + data_split_mode=int(data_split_mode), + ), ctypes.byref(handle), ) ) @@ -1046,7 +1051,9 @@ def dispatch_data_backend( data.tocsr(), missing, threads, feature_names, feature_types ) if _is_numpy_array(data): - return _from_numpy_array(data, missing, threads, feature_names, feature_types) + return _from_numpy_array( + data, missing, threads, feature_names, feature_types, data_split_mode + ) if _is_uri(data): return _from_uri(data, missing, feature_names, feature_types, data_split_mode) if _is_list(data): diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index e0f2d47b0722..06bd43b2be34 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -463,8 +463,11 @@ XGB_DLL int XGDMatrixCreateFromDense(char const *data, auto config = Json::Load(StringView{c_json_config}); float missing = GetMissing(config); auto n_threads = OptionalArg(config, "nthread", 0); + auto data_split_mode = + static_cast(OptionalArg(config, "data_split_mode", 0)); xgboost_CHECK_C_ARG_PTR(out); - *out = new std::shared_ptr(DMatrix::Create(&adapter, missing, n_threads)); + *out = new std::shared_ptr( + DMatrix::Create(&adapter, missing, n_threads, "", data_split_mode)); API_END(); }