From cd1d108c7dfd9e4ff9a0843e5ff55d93a287dd6f Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 3 Jul 2024 22:52:26 +0800 Subject: [PATCH] [doc] Fix learning to rank tutorial. [skip ci] (#10539) --- doc/tutorials/learning_to_rank.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/tutorials/learning_to_rank.rst b/doc/tutorials/learning_to_rank.rst index 74e52e156..4d2cbad4a 100644 --- a/doc/tutorials/learning_to_rank.rst +++ b/doc/tutorials/learning_to_rank.rst @@ -72,8 +72,11 @@ Please note that, as of writing, there's no learning-to-rank interface in scikit .. code-block:: python import pandas as pd + + # `X`, `qid`, and `y` are from the previous snippet, they are all sorted by the `sorted_idx`. df = pd.DataFrame(X, columns=[str(i) for i in range(X.shape[1])]) - df["qid"] = qid[sorted_idx] + df["qid"] = qid + ranker.fit(df, y) # No need to pass qid as a separate argument from sklearn.model_selection import StratifiedGroupKFold, cross_val_score