Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 31, 2023
1 parent cd81097 commit 0fcff38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion python-package/xgboost/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def make_position_biased_ltr(
n_samples: int, n_features: int, n_query_groups: int, max_rel: int
) -> ClickFold:
"""Generate position-biased data for testing learning to rank."""
datasets = pytest.importorskip("sklearn.datasets")
ms = pytest.importorskip("sklearn.model_selection")
# from sklearn.model_selection import train_test_split
X, y = datasets.make_classification(n_samples, n_features, n_classes=max_rel)
Expand Down
9 changes: 6 additions & 3 deletions python-package/xgboost/testing/data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=invalid-name
"""Utilities for data generation."""
import os
import zipfile
Expand Down Expand Up @@ -349,15 +350,18 @@ def get_mq2008(


class RelDataCV(NamedTuple):
"""Simple data struct for train-test split."""

train: RelData
test: RelData
max_rel: int

def is_binary(self) -> bool:
"""Whether it's binary relevance."""
return self.max_rel == 1


class PBM:
class PBM: # pylint: disable=too-few-public-methods
"""Simulate click data with position bias model. There are other models available in
`ULTRA <https://github.com/ULTR-Community/ULTRA.git>`_ like the cascading model.
Expand Down Expand Up @@ -470,7 +474,6 @@ def simulate_one_fold(
"""Simulate clicks for one fold."""
X_fold, y_fold, qid_fold = fold
assert qid_fold.dtype == np.int32
indptr, lengths, values = rlencode(qid_fold)

qids = np.unique(qid_fold)

Expand Down Expand Up @@ -554,7 +557,7 @@ def sort_ltr_samples(
qid = qid[sorted_idx]
pos = pos[sorted_idx]

indptr, lengths, values = rlencode(qid)
indptr, _, _ = rlencode(qid)

for i in range(1, indptr.size):
beg = indptr[i - 1]
Expand Down

0 comments on commit 0fcff38

Please sign in to comment.