Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XGBoost: Convert dmatrix into a numpy.array

I'd like to inspect the DMatrix object. The documentation mentions the methods to get the number of rows and columns and also the slice at each row:

dmatrix.slice(index)

But I'd like to do more complex transformations using numpy. Is there a simple way to convert the DMatrix to a numpy array?

like image 669
Pek Avatar asked Nov 08 '22 12:11

Pek


1 Answers

DMatrix is a one-way street! Once you get DMatrix, you cannot get back its content as numpy.ndarray or pandas.DataFrame.

[Update] A library is implemented only for the particular task of convert XGBoost's DMatrix format to numpy.array: https://github.com/aporia-ai/dmatrix2np

like image 164
Amir Avatar answered Nov 14 '22 21:11

Amir