Skip to content
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

Better handling of NaNs #15

Closed
nicodv opened this issue May 27, 2016 · 2 comments
Closed

Better handling of NaNs #15

nicodv opened this issue May 27, 2016 · 2 comments

Comments

@nicodv
Copy link
Owner

nicodv commented May 27, 2016

np.unique is used for encoding data values to integers. However, numpy currently treats every np.NaN as a unique value, creating many categories. (See: numpy/numpy#2111)

Solution is to check with np.isnan so that we can just ignore all NaNs when encoding. The encoder then simply assigns all NaNs to the -1 (i.e. "I don't know this value") category.

@nicodv nicodv closed this as completed in 6fd7c98 May 27, 2016
@allefeld
Copy link

allefeld commented Jul 6, 2019

@nicodv, could you expand on this a bit, or give a code example? How does one "check with np.isnan" when using np.unique? Also, a remark in the documentation of np.unique would be useful.

@nicodv
Copy link
Owner Author

nicodv commented Jul 8, 2019

@allefeld , have a look at the commit that fixes this issue: 6fd7c98

It basically filters out NaNs in the encoding and makes sure they get a -1 value.

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

No branches or pull requests

2 participants