Skip to content

Follow force_all_finite for object dtype in check_array #13254

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

Merged

Conversation

jorisvandenbossche
Copy link
Member

Tries to resolve part of #12148.

Currently, check_array does not check for nan/inf when the data is object dtype. But eg in OneHotEncoder, this is actually needed, and there some additional custom code was added after calling check_array. This PR basically moves that into check_array.

For now, I only check for np.nan, and not yet np.inf.

@glemaitre
Copy link
Member

Do you want to modify all estimators which are in this case as well?

@jorisvandenbossche
Copy link
Member Author

Question here: do we want to check for np.inf for object dtype data?

To be fully consistent, we should probably do that, since we check it for numeric data. But in practice, I suppose it will hardly ever come up (as opposed to np.nan in object dtype data), and checking it for object dtype is also much less efficient than checking it for float dtype. So from practical point of view, we could also just document it in check_array that this case is not covered (although no user will ever read it there of course ..).

@jnothman
Copy link
Member

Happy to not worry about inf in object dtype...

@jnothman jnothman merged commit 20f64eb into scikit-learn:master Mar 1, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
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.

4 participants