[doc] Fix python docs (#10058)

This commit is contained in:
UncleLLD 2024-02-22 17:34:12 +08:00 committed by GitHub
parent 2e4ea5ecc0
commit b9171d8f0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -36,7 +36,7 @@ inside iteration loop. You can also pass this callback function directly into X
# Specify which dataset and which metric should be used for early stopping. # Specify which dataset and which metric should be used for early stopping.
early_stop = xgb.callback.EarlyStopping(rounds=early_stopping_rounds, early_stop = xgb.callback.EarlyStopping(rounds=early_stopping_rounds,
metric_name='CustomErr', metric_name='CustomErr',
data_name='Train') data_name='Valid')
booster = xgb.train( booster = xgb.train(
{'objective': 'binary:logistic', {'objective': 'binary:logistic',

View File

@ -62,7 +62,7 @@ stack of trees:
.. code-block:: python .. code-block:: python
early_stop = xgb.callback.EarlyStopping( early_stop = xgb.callback.EarlyStopping(
rounds=2, metric_name='logloss', data_name='Validation_0', save_best=True rounds=2, metric_name='logloss', data_name='validation_0', save_best=True
) )
clf = xgb.XGBClassifier(tree_method="hist", callbacks=[early_stop]) clf = xgb.XGBClassifier(tree_method="hist", callbacks=[early_stop])
clf.fit(X_train, y_train, eval_set=[(X_test, y_test)]) clf.fit(X_train, y_train, eval_set=[(X_test, y_test)])