0
$\begingroup$

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?

$\endgroup$
3
$\begingroup$

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.

| improve this answer | |
$\endgroup$
1
$\begingroup$

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’)
```
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.