MCPcopy Create free account
hub / github.com/dmlc/xgboost / _from_numpy_array

Function _from_numpy_array

python-package/xgboost/data.py:269–293  ·  view source on GitHub ↗

Initialize data from a 2-D numpy matrix.

(
    *,
    data: np.ndarray,
    missing: FloatCompatible,
    nthread: int,
    feature_names: Optional[FeatureNames],
    feature_types: Optional[FeatureTypes],
    data_split_mode: DataSplitMode = DataSplitMode.ROW,
)

Source from the content-addressed store, hash-verified

267
268
269def _from_numpy_array(
270 *,
271 data: np.ndarray,
272 missing: FloatCompatible,
273 nthread: int,
274 feature_names: Optional[FeatureNames],
275 feature_types: Optional[FeatureTypes],
276 data_split_mode: DataSplitMode = DataSplitMode.ROW,
277) -> DispatchedDataBackendReturnType:
278 """Initialize data from a 2-D numpy matrix."""
279 _check_data_shape(data)
280 data, _ = _ensure_np_dtype(data, data.dtype)
281 handle = ctypes.c_void_p()
282 _check_call(
283 _LIB.XGDMatrixCreateFromDense(
284 array_interface(data),
285 make_jcargs(
286 missing=float(missing),
287 nthread=int(nthread),
288 data_split_mode=int(data_split_mode),
289 ),
290 ctypes.byref(handle),
291 )
292 )
293 return handle, feature_names, feature_types
294
295
296_pandas_dtype_mapper = {

Callers 3

_from_pandas_seriesFunction · 0.85
_from_listFunction · 0.85
dispatch_data_backendFunction · 0.85

Calls 5

_check_data_shapeFunction · 0.85
_ensure_np_dtypeFunction · 0.85
_check_callFunction · 0.85
array_interfaceFunction · 0.85
make_jcargsFunction · 0.85

Tested by

no test coverage detected