Anurag Upadhyaya
Anurag Upadhyaya

Reputation: 233

Unable to create XGBoost DMatrix

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.

Upvotes: 4

Views: 2516

Answers (1)

Eduard Ilyasov
Eduard Ilyasov

Reputation: 3308

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)

Upvotes: 4

Related Questions