-
Notifications
You must be signed in to change notification settings - Fork 9
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
Silent mis-handling of NaNs in input data #7
Comments
Ah, interestingly, if I replace occurrences of np.nan with np.inf, at least they don't affect calculations with unrelated variables, so this may be a work-around. Also, the MI between two random variables where one contains np.infs is lower the more np.infs there are, not sure if that makes sense or not... Another potentially helpful observation is that the calculations seem to finish much quicker in the presence of NaNs, as if some code paths or parts of the data are being skipped (noticeable with larger datasets). |
FWIW, here is the output of # No missing data:
************************ SNAPSHOT ************************
Number of total datapoints added = 100
Number of populated bins = 97
Has data been collapsed across multiple shifted binnings? Yes
Size of average binned data = 97
**********************************************************
# 10 NaNs in variable with id 2:
************************ SNAPSHOT ************************
Number of total datapoints added = 100
Number of populated bins = 89
Has data been collapsed across multiple shifted binnings? Yes
Size of average binned data = 89
**********************************************************
# 10 Infs in variable with id 2:
************************ SNAPSHOT ************************
Number of total datapoints added = 100
Number of populated bins = 99
Has data been collapsed across multiple shifted binnings? Yes
Size of average binned data = 99
********************************************************** |
Hi, you're probably not even maintaining this anymore, but in case you do, I've found that NaNs in the input data are not handled correctly, I think. In case you want to add something about this in the docs...
I'm not sure exactly what happens, but if I have a matrix with 3 columns, and I make some values in the third column NaNs, that will affect calculations of MI between the first two:
Without NaNs in the third variable the resulting MI between the first two variables is 0.6699268749439261. With NaNs, the result is 0.7039212101565637. So the strange thing is that data in an unrelated variable affects the MI between the first two.
After a quick Iook only, one thing that may be happening is that
PyFloat_AsDouble
may silently convert NaNs to -1 (https://docs.python.org/3/c-api/float.html#c.PyFloat_AsDouble) perhaps? Which would then mean that the minima passed in are not correct anymore. Though I don't know how this would then affect unrelated variables.Let me know if you want me to help out addressing this, if you're still aiming to support this package.
Btw, I'm an old friend of Eduardo Izquierdo's ;)
The text was updated successfully, but these errors were encountered: