Hi Everyone,
I want to solve a classification problem which has 10 classes to predict.
my train and validation datasets are prepared properly.
here is my code. Please let me know why this error is coming.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=100)
Success
print (“Training and testing split was successful.”)
import xgboost as xgb
dtrain = xgb.DMatrix(X_train, label=y_train)
dtest = xgb.DMatrix(X_test, label=y_test)
param = {
‘max_depth’: 3, # the maximum depth of each tree
‘eta’: 0.3, # the training step for each iteration
‘silent’: 1, # logging mode - quiet
‘objective’: ‘multi:softprob’, # error evaluation for multiclass training
‘num_class’: 10} # the number of classes that exist in this datset
num_round = 20 # the number of training iterations
bst = xgb.train(param, dtrain, num_round)
preds = bst.predict(dtest)
this is where I am getting error and here is the error message.
TypeError Traceback (most recent call last)
in ()
----> 1 preds = bst.predict(dtest)
~\Anaconda3\lib\site-packages\xgboost-0.40-py3.6.egg\xgboost.py in predict(self, data, output_margin, ntree_limit, pred_leaf)
472 nrow = data.num_row()
473 if preds.size != nrow and preds.size % nrow == 0:
–> 474 preds = preds.reshape(nrow, preds.size / nrow)
475 return preds
476
TypeError: ‘float’ object cannot be interpreted as an integer
Please help on how to resolve this.