is there cross validation for xgb classification for multi labels?
I have been search but can not find any cross validation for xgb classifier
is using cross validation for xgb or xgb classifier worth?
and is there any example I can find?
2 Answers
Single or multi label doesn't make the difference. Cross validation is only split methodology. It just divides records in your data set to separate train and test splits. Python wrapper implements scikit API, so it'll work with any of the selection methods. Metrics will work too. Just remember to one-hot encode your labels.
Is using cross validation for xgb or xgb classifier worth? and is there any example I can find?
If you only can afford it, do it for every pipeline you can. You split the data to see how your model generalizes new, unseen records. These splits are randomized, so you preferably would like to repeat it some number of times in a way all of the records has been used some times for training and testing. That's what cross validation does. It's best to obtain distribution of metrics from 50-100 train/test cycles.
GridsearchCV accepts multiclassification task automatically, same as XgbClassifier.
As an example, something like this would work:
xgb_model = xgb.XGBClassifier()
parameters = {'max_depth': [6,7,8],
'seed': [1337]}
clf = GridSearchCV(xgb_model, parameters, n_jobs=5,
n_folds=5, shuffle=True),
scoring=‘f1_macro’)
```