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,
)
| 267 | |
| 268 | |
| 269 | def _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 = { |
no test coverage detected