Update Python docstring for ranking functions (#4121)

* Update Python docstring for ranking functions

* Fix formatting
This commit is contained in:
Philip Hyunsu Cho 2019-02-10 12:22:02 -08:00 committed by GitHub
parent 3320a52192
commit 99a290489c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 3 deletions

View File

@ -351,6 +351,14 @@ class DMatrix(object):
None, defaults to np.nan. None, defaults to np.nan.
weight : list or numpy 1-D array , optional weight : list or numpy 1-D array , optional
Weight for each instance. Weight for each instance.
.. note:: For ranking task, weights are per-group.
In ranking task, one weight is assigned to each group (not each data
point). This is because we only care about the relative ordering of
data points within each group, so it doesn't make sense to assign
weights to individual data points.
silent : boolean, optional silent : boolean, optional
Whether print messages during construction Whether print messages during construction
feature_names : list, optional feature_names : list, optional
@ -655,6 +663,13 @@ class DMatrix(object):
---------- ----------
weight : array like weight : array like
Weight for each data point Weight for each data point
.. note:: For ranking task, weights are per-group.
In ranking task, one weight is assigned to each group (not each data
point). This is because we only care about the relative ordering of
data points within each group, so it doesn't make sense to assign
weights to individual data points.
""" """
self.set_float_info('weight', weight) self.set_float_info('weight', weight)
@ -666,6 +681,13 @@ class DMatrix(object):
---------- ----------
weight : array like weight : array like
Weight for each data point in numpy 2D array Weight for each data point in numpy 2D array
.. note:: For ranking task, weights are per-group.
In ranking task, one weight is assigned to each group (not each data
point). This is because we only care about the relative ordering of
data points within each group, so it doesn't make sense to assign
weights to individual data points.
""" """
self.set_float_info_npy2d('weight', weight) self.set_float_info_npy2d('weight', weight)

View File

@ -885,7 +885,7 @@ class XGBRanker(XGBModel):
Whether to print messages while running boosting. Whether to print messages while running boosting.
objective : string objective : string
Specify the learning task and the corresponding learning objective. Specify the learning task and the corresponding learning objective.
Only "rank:pairwise" is supported currently. The objective name must start with "rank:".
booster: string booster: string
Specify which booster to use: gbtree, gblinear or dart. Specify which booster to use: gbtree, gblinear or dart.
nthread : int nthread : int
@ -999,13 +999,29 @@ class XGBRanker(XGBModel):
group : array_like group : array_like
group size of training data group size of training data
sample_weight : array_like sample_weight : array_like
instance weights group weights
.. note:: Weights are per-group for ranking tasks
In ranking task, one weight is assigned to each group (not each data
point). This is because we only care about the relative ordering of
data points within each group, so it doesn't make sense to assign
weights to individual data points.
eval_set : list, optional eval_set : list, optional
A list of (X, y) tuple pairs to use as a validation set for A list of (X, y) tuple pairs to use as a validation set for
early-stopping early-stopping
sample_weight_eval_set : list, optional sample_weight_eval_set : list, optional
A list of the form [L_1, L_2, ..., L_n], where each L_i is a list of A list of the form [L_1, L_2, ..., L_n], where each L_i is a list of
instance weights on the i-th validation set. group weights on the i-th validation set.
.. note:: Weights are per-group for ranking tasks
In ranking task, one weight is assigned to each group (not each data
point). This is because we only care about the relative ordering of
data points within each group, so it doesn't make sense to assign
weights to individual data points.
eval_group : list of arrays, optional eval_group : list of arrays, optional
A list that contains the group size corresponds to each A list that contains the group size corresponds to each
(X, y) pair in eval_set (X, y) pair in eval_set