Skip to content

Commit

Permalink
Address comments in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudioSalvatoreArcidiacono committed Dec 18, 2024
1 parent 4cbfc84 commit 93acf6a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,6 @@ def _process_params(self, stage: str) -> Dict[str, Any]:
params["random_state"] = params["random_state"].randint(np.iinfo(np.int32).max)
elif isinstance(params["random_state"], np.random.Generator):
params["random_state"] = int(params["random_state"].integers(np.iinfo(np.int32).max))

if self._n_classes > 2:
for alias in _ConfigAliases.get("num_class"):
params.pop(alias, None)
Expand Down
3 changes: 1 addition & 2 deletions tests/python_package_test/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_early_stopping_is_deactivated_by_default_lambdarank():
q_train = np.loadtxt(str(rank_example_dir / "rank.train.query"))
n_estimators = 5
gbm = lgb.LGBMRanker(n_estimators=n_estimators, random_state=42, verbose=-1)
gbm.fit(X_train, y_train, group=q_train) # Assuming 10 samples in one group
gbm.fit(X_train, y_train, group=q_train)

# Check that early stopping did not kick in
assert gbm._Booster.params.get("early_stopping_round") is None
Expand All @@ -377,7 +377,6 @@ def test_auto_early_stopping_lambdarank():
y_train,
group=q_train,
eval_at=[1, 3],
callbacks=[lgb.reset_parameter(learning_rate=lambda x: max(0.01, 0.1 - 0.01 * x))],
)
assert gbm._Booster.params["early_stopping_round"] == 10
assert gbm._Booster.num_trees() < n_estimators
Expand Down

0 comments on commit 93acf6a

Please sign in to comment.