Unable to create XGBoost DMatrix

2.4k views Asked by At

What i understand is DMatrix accepts numpy.ndarray as input. I have tried this multiple times now and its not letting me create a DMatrix.

Error Screenshot

I have tried using Xgboost.DMatrix and Xgboost.sklearn.DMatrix. Any help would be high appreciable.

1

There are 1 answers

0
Eduard Ilyasov On BEST ANSWER

It seems like your y_train is a numpy array with non-numerical elements. You should transform y_train elements to numerical type.

You can do it that way:

from sklearn import preprocessing
encoder = preprocessing.LabelEncoder()
y_train = encoder.fit_transform(y_train)