Perform the cross-validation with given paramaters. Parameters ---------- params : dict Parameters for Booster. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. folds : generator o
(params, train_set, num_boost_round=100,
folds=None, nfold=5, stratified=True, shuffle=True,
metrics=None, fobj=None, feval=None, init_model=None,
feature_name='auto', categorical_feature='auto',
early_stopping_rounds=None, fpreproc=None,
verbose_eval=None, show_stdv=True, seed=0,
callbacks=None, eval_train_metric=False)
| 370 | |
| 371 | |
| 372 | def cv(params, train_set, num_boost_round=100, |
| 373 | folds=None, nfold=5, stratified=True, shuffle=True, |
| 374 | metrics=None, fobj=None, feval=None, init_model=None, |
| 375 | feature_name='auto', categorical_feature='auto', |
| 376 | early_stopping_rounds=None, fpreproc=None, |
| 377 | verbose_eval=None, show_stdv=True, seed=0, |
| 378 | callbacks=None, eval_train_metric=False): |
| 379 | """Perform the cross-validation with given paramaters. |
| 380 | |
| 381 | Parameters |
| 382 | ---------- |
| 383 | params : dict |
| 384 | Parameters for Booster. |
| 385 | train_set : Dataset |
| 386 | Data to be trained on. |
| 387 | num_boost_round : int, optional (default=100) |
| 388 | Number of boosting iterations. |
| 389 | folds : generator or iterator of (train_idx, test_idx) tuples, scikit-learn splitter object or None, optional (default=None) |
| 390 | If generator or iterator, it should yield the train and test indices for each fold. |
| 391 | If object, it should be one of the scikit-learn splitter classes |
| 392 | (https://scikit-learn.org/stable/modules/classes.html#splitter-classes) |
| 393 | and have ``split`` method. |
| 394 | This argument has highest priority over other data split arguments. |
| 395 | nfold : int, optional (default=5) |
| 396 | Number of folds in CV. |
| 397 | stratified : bool, optional (default=True) |
| 398 | Whether to perform stratified sampling. |
| 399 | shuffle : bool, optional (default=True) |
| 400 | Whether to shuffle before splitting data. |
| 401 | metrics : string, list of strings or None, optional (default=None) |
| 402 | Evaluation metrics to be monitored while CV. |
| 403 | If not None, the metric in ``params`` will be overridden. |
| 404 | fobj : callable or None, optional (default=None) |
| 405 | Customized objective function. |
| 406 | Should accept two parameters: preds, train_data, |
| 407 | and return (grad, hess). |
| 408 | |
| 409 | preds : list or numpy 1-D array |
| 410 | The predicted values. |
| 411 | train_data : Dataset |
| 412 | The training dataset. |
| 413 | grad : list or numpy 1-D array |
| 414 | The value of the first order derivative (gradient) for each sample point. |
| 415 | hess : list or numpy 1-D array |
| 416 | The value of the second order derivative (Hessian) for each sample point. |
| 417 | |
| 418 | For multi-class task, the preds is group by class_id first, then group by row_id. |
| 419 | If you want to get i-th row preds in j-th class, the access way is score[j * num_data + i] |
| 420 | and you should group grad and hess in this way as well. |
| 421 | |
| 422 | feval : callable or None, optional (default=None) |
| 423 | Customized evaluation function. |
| 424 | Should accept two parameters: preds, train_data, |
| 425 | and return (eval_name, eval_result, is_higher_better) or list of such tuples. |
| 426 | |
| 427 | preds : list or numpy 1-D array |
| 428 | The predicted values. |
| 429 | train_data : Dataset |
nothing calls this directly
no test coverage detected