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


#1

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)))


#2

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


#3

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