From 0da7d872ef6b5fd3ffb1dc8f5189d7e4fafa807e Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Tue, 15 Feb 2022 05:01:55 +0800 Subject: [PATCH] [doc] Update for prediction. (#7648) --- demo/guide-python/predict_leaf_indices.py | 4 +++- doc/parameter.rst | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/demo/guide-python/predict_leaf_indices.py b/demo/guide-python/predict_leaf_indices.py index 2bfc37e3a..23b96a752 100644 --- a/demo/guide-python/predict_leaf_indices.py +++ b/demo/guide-python/predict_leaf_indices.py @@ -16,7 +16,9 @@ bst = xgb.train(param, dtrain, num_round, watchlist) print('start testing predict the leaf indices') # predict using first 2 tree -leafindex = bst.predict(dtest, ntree_limit=2, pred_leaf=True) +leafindex = bst.predict( + dtest, iteration_range=(0, 2), pred_leaf=True, strict_shape=True +) print(leafindex.shape) print(leafindex) # predict all trees diff --git a/doc/parameter.rst b/doc/parameter.rst index 2189cf65d..d341baa8b 100644 --- a/doc/parameter.rst +++ b/doc/parameter.rst @@ -267,12 +267,12 @@ Additional parameters for Dart Booster (``booster=dart``) If the booster object is DART type, ``predict()`` will perform dropouts, i.e. only some of the trees will be evaluated. This will produce incorrect results if ``data`` is - not the training data. To obtain correct results on test sets, set ``ntree_limit`` to + not the training data. To obtain correct results on test sets, set ``iteration_range`` to a nonzero value, e.g. .. code-block:: python - preds = bst.predict(dtest, ntree_limit=num_round) + preds = bst.predict(dtest, iteration_range=(0, num_round)) * ``sample_type`` [default= ``uniform``]