0

I have been struggling to get python's xgboost to accept targets due to their shape (I have tried shapes of (-1,1) vs (-1,), format of pandas vs numpy, and LabelBinarizing vs One-hot-encoding the target). Any advice to get this going?

import numpy as np
x = np.random.randint(0, 25, size = (1000, 10))
y = np.random.randint(0, 5, size = (1000, 1))

clf = xgb.XGBClassifier()

x = xgb.DMatrix(x)
y = xgb.DMatrix(y)

clf.fit(x, y)

ValueError: bad input shape ()
Anthony M
  • 109
  • 8

1 Answers1

0

With XGBoost DMatrix as an input you dont use clf.fit(), only xgb.train(). Clf.fit() expects array in the input.
References:
Get started xgboost
XGBClassifier.fit()
xgboost.train()

crusher083
  • 171
  • 2
  • 10