[doc] Fix learning to rank tutorial. [skip ci] (#10539)
This commit is contained in:
parent
6243e7c43d
commit
cd1d108c7d
@ -72,8 +72,11 @@ Please note that, as of writing, there's no learning-to-rank interface in scikit
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import pandas as pd
|
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 = 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
|
ranker.fit(df, y) # No need to pass qid as a separate argument
|
||||||
|
|
||||||
from sklearn.model_selection import StratifiedGroupKFold, cross_val_score
|
from sklearn.model_selection import StratifiedGroupKFold, cross_val_score
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user