best_ntree_limit attribute added
- best_ntree_limit as new booster atrribute added - usage of bst.best_ntree_limit in python doc added - fixed wrong 'best_iteration' after training continuation
This commit is contained in:
@@ -121,7 +121,7 @@ Early stopping requires at least one set in `evals`. If there's more than one, i
|
||||
|
||||
The model will train until the validation score stops improving. Validation error needs to decrease at least every `early_stopping_rounds` to continue training.
|
||||
|
||||
If early stopping occurs, the model will have two additional fields: `bst.best_score` and `bst.best_iteration`. Note that `train()` will return a model from the last iteration, not the best one.
|
||||
If early stopping occurs, the model will have three additional fields: `bst.best_score`, `bst.best_iteration` and `bst.best_ntree_limit`. Note that `train()` will return a model from the last iteration, not the best one.
|
||||
|
||||
This works with both metrics to minimize (RMSE, log loss, etc.) and to maximize (MAP, NDCG, AUC). Note that if you specify more than one evaluation metric the last one in `param['eval_metric']` is used for early stopping.
|
||||
|
||||
@@ -135,9 +135,9 @@ dtest = xgb.DMatrix(data)
|
||||
ypred = bst.predict(xgmat)
|
||||
```
|
||||
|
||||
If early stopping is enabled during training, you can predict with the best iteration.
|
||||
If early stopping is enabled during training, you can get predicticions from the best iteration with `bst.best_ntree_limit`:
|
||||
```python
|
||||
ypred = bst.predict(xgmat,ntree_limit=bst.best_iteration)
|
||||
ypred = bst.predict(xgmat,ntree_limit=bst.best_ntree_limit)
|
||||
```
|
||||
|
||||
Plotting
|
||||
|
||||
Reference in New Issue
Block a user