-
Notifications
You must be signed in to change notification settings - Fork 1
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
validator error #7
Comments
In the Indeed, when I test the normalizedMI class with independent random sequences, it correctly estimates 0 mutual information between random sequences, but throw error due to the beartype type checking |
@braniii I have been getting a similar error when calling fit or fit_transform. I am not able to share the data I am working with, but have included the error details. There are 2 features, with the same dimensions, containing floats. Thank you! BeartypeCallHintReturnViolation: Function normi._estimators.kraskov_estimator() return (0.0, -33.75037660839038, -21.184763217160228, -13.703348491372974) violates type hint tuple[typing.Annotated[typing.Union[float, numpy.floating], beartype.vale.Is[lambda arr: bool(np.all(arr > 0))]], typing.Union[float, numpy.floating], typing.Union[float, numpy.floating], typing.Union[float, numpy.floating]], as tuple index 0 item <class "numpy.float64"> 0.0 violates validator beartype.vale.Is[lambda arr: bool(np.all(arr > 0))]: |
@braniii from an initial look (and quite a basic understanding of what is happening here), it seems that the MI value returned by the kraskov_estimator function is required to be a PositiveFloat, which in turn is required to be of type IsStrictlyPositive, so an MI value of 0.0 results in an error - should this requirement be positive, and not strictly positive? |
@ABarcaru @jessLryan sorry for the inconvenience. I guess that the limitation is the assumption of local constant density in the KSG estimator (which this method is based on). I will try to have a look into it. |
presumably, if MI is zero, then NMI also ought to be zero? |
@braniii and others, a quick and dirty fix that worked for me is to replace the return call from the
to
I used to work a lot (not anymore) with the ksg estimator for MI estimation and it was often that we needed those dirty fixes on real-world data. |
Hi, I am trying to use the python application of this script.
nmi = NormalizedMI(normalize_method='joint', k=5 , verbose=False, n_dims = 1)
nmi.fit_transform(X)
and I am hitting the same error:
"BeartypeCallHintReturnViolation: Function normi._estimators.kraskov_estimator() return (np.float64(0.0), np.float64(2.084952429900486), np.float64(1.0187914941452727), np.float64...)) violates type hint tuple[typing.Annotated[typing.Union[float, numpy.floating], Is[lambda arr: bool(np.all(arr > 0))]], typing.Union[float, numpy.floating], typing.Union[float, numpy.floating], typing.Union[float, numpy.floating]], as tuple index 0 item <class "numpy.float64"> np.float64(0.0) violates validator Is[lambda arr: bool(np.all(arr > 0))]:
False == Is[lambda arr: bool(np.all(arr > 0))]."
My X is a numpy array 56x20, dtype float. It works in two other cases of the same size and same instantiation but fails in this one.
What could be the problem ?
test_array.csv
The text was updated successfully, but these errors were encountered: