Reputation: 233
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.
I have tried using Xgboost.DMatrix and Xgboost.sklearn.DMatrix. Any help would be high appreciable.
Upvotes: 4
Views: 2516
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