Skip to content

Commit 3f47fcb

Browse files
authored
[backport][doc] Fix learning to rank tutorial. [skip ci] (dmlc#10539) (dmlc#10578)
1 parent 0618c20 commit 3f47fcb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doc/tutorials/learning_to_rank.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ Please note that, as of writing, there's no learning-to-rank interface in scikit
7171

7272
.. code-block:: python
7373
74+
import pandas as pd
75+
76+
# `X`, `qid`, and `y` are from the previous snippet, they are all sorted by the `sorted_idx`.
7477
df = pd.DataFrame(X, columns=[str(i) for i in range(X.shape[1])])
75-
df["qid"] = qid[sorted_idx]
78+
df["qid"] = qid
79+
7680
ranker.fit(df, y) # No need to pass qid as a separate argument
7781
7882
from sklearn.model_selection import StratifiedGroupKFold, cross_val_score

0 commit comments

Comments
 (0)