Skip to content

Commit d893286

Browse files
authored
TST FIX binary y in sample weight equivalence check (scikit-learn#30775)
1 parent 956b7e5 commit d893286

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- In :mod:`utils.estimator_checks` we now enforce for binary classifiers a
2+
binary `y` by taking the minimum as the negative class instead of the first
3+
element, which makes it robust to `y` shuffling. It prevents two checks from
4+
wrongly failing on binary classifiers.
5+
By :user:`Antoine Baker <antoinebaker>`.

sklearn/utils/estimator_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3934,7 +3934,7 @@ def _enforce_estimator_tags_y(estimator, y):
39343934
and not tags.classifier_tags.multi_class
39353935
and y.size > 0
39363936
):
3937-
y = np.where(y == y.flat[0], y, y.flat[0] + 1)
3937+
y = np.where(y == y.min(), y, y.min() + 1)
39383938
# Estimators in mono_output_task_error raise ValueError if y is of 1-D
39393939
# Convert into a 2-D y for those estimators.
39403940
if tags.target_tags.multi_output and not tags.target_tags.single_output:

0 commit comments

Comments
 (0)