0

I am using XGBoost model for my data. I need to collect all the received values in a Dataframe.

x_train (pandas.core.frame.DataFrame) is 9 columns,

pred_prob (numpy.ndarray) is 5 columns,

y_test (numpy.ndarray) is 1 column,

pred (numpy.ndarray) is 1 column.

How can i do this?

When trying to build pred_prob, y_test, pred,

df = pd.DataFrame (np.concatenate (pred_prob, pred, y_test), axis = 0)

the following error occurs:

TypeError: only integer scalar arrays can be converted to a scalar index

1 Answer 1

1

Give a tuple of ndarrays and axis=1 to np.concatenate (works only if ndarrays have same number of rows) :

df = pd.DataFrame(np.concatenate((pred_prob, pred, y_test), axis=1))
Sign up to request clarification or add additional context in comments.

6 Comments

My data [ … [0.17250077 0.17303202 0.17306072 0.30882448 0.17258205] [0.14553823 0.14860761 0.39314887 0.16709846 0.1456068 ]] [2 3 4 1 1 1 3 3 2 4 1 2 4 0 3 4 2 2 3 1] [2 3 4 1 1 1 3 3 4 4 1 2 4 0 3 4 4 2 3 1]
does not work even if I only use pred, y_test, again the same error
Have your tried my exact code and checked that all your matrices have same number of rows ?
pred_prob matrix 20 ,5
pred, y_test - 20,
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.