What is the different between xgboost.Classifier and xgboost.train from API Level in python environment

As the title said, I think the different between xgboost.Classifier and xgboost.train is the input label data in xgboost.Classifier can be a String type, but the input label in xgboost.train part can not be a String type? (xgboost.train(params, xgboost.DMatrix(data, labels)))

I get this Error when I use xgboost.train, but when I use xgboost.Classifier to train the same data it is OK

model = xgb.train(params, xgb.DMatrix(trains_X, trains_Y))

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/xgboost/core.py”, line 395, in init
self.set_label_npy2d(label)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/xgboost/core.py”, line 632, in set_label_npy2d
self.set_float_info_npy2d(‘label’, label)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/xgboost/core.py”, line 576, in set_float_info_npy2d
data = np.array(data, copy=False, dtype=np.float32)
ValueError: could not convert string to float: s_2871718

XGBClassifier supports automatic conversion from string labels to numeric labels, to follow conventions of scikit-learn.

I have noticed similar issue with xgb.DMatrix. Is there any alternative solution as preprocess step to convert string to float ? Appreciate your help.

You may manually convert string labels into integer labels (0, 1, 2, …).