Skip to content

FIX CalibratedClassifierCV with string targets #28843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jeremiedbb
Copy link
Member

@jeremiedbb jeremiedbb commented Apr 15, 2024

Fixes #28841

By removing _validate_data, #19555 introduced a regression in CalibratedClassifierCV. This is due to how numpy behaves with element-wise comparison of arrays of strings.

y = ["1", "1", "2", "2"]
c = np.array(["1", "2"])

# before, y was validated, hence was an array
np.array(y) == c[0]
# array([ True,  True, False, False])

# now, y is not validated, hence still a list
y == c[0]
# False

Surprisingly, the second one works with integers.

Using np.unique will work no matter what to count the number of occurrences.

@jeremiedbb jeremiedbb added this to the 1.5 milestone Apr 15, 2024
Copy link

github-actions bot commented Apr 15, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 9130934. Link to the linter CI: here

@adrinjalali
Copy link
Member

cc @OmarManzoor @Charlie-XIAO maybe?

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jeremiedbb

@OmarManzoor OmarManzoor merged commit 481b457 into scikit-learn:main Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 1.0 breaks cross-validation with string targets
3 participants