Is there a way to print a DMatrix as ASCII or JSON?

Hi folks.

Is there a way to print a DMatrix as ASCII or JSON from CPython 3.6?

If not, is there a way to just iterate over a DMatrix’ rows and columns from CPython 3.6?


I’m afraid currently it is not possible. What is your use case for iterating over a DMatrix? Do you have access to the original data source?

While I’m not the original person who asked, I would like that functionality too. The reason I want it is because I don’t understand the toy example you have for fitting an AFT model. If I could see how the X input to the training function was structured, I think it would make more sense. To clarify, I get why the input has to include outcome pairs. However, the lower and upper bound numbers make no sense to me. For example, y_lower_bound = np.array([ 2.0, 3.0, 0.0, 4.0]). What do the 2, 3 and 4 represent? Are they the data times? Are they a code for a type of bound? How does this fit with they X array you had above? It is completely unclear.

@angelgeek Take a look at The paper contains two simulations where the (censored) event times are generated from the data matrix X.