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

BUG : Spearman correlation error generated from missing otypes in np.vectorize #61

Open
AndraIonescu opened this issue Jun 16, 2023 · 0 comments
Assignees

Comments

@AndraIonescu
Copy link

Description:
Python version: 3.8
numpy version: 1.22.3
ITMO_FS version: 0.3.3

When y.shape and x.shape are different, spearman_correlation fails because of missing "otypes" in np.vectorise.

This happens from np.vectorise - numpy/lib/function_base.py - _get_ufunc_and_otypes() - line 2365
otypes = ''.join([asarray(outputs[_k]).dtype.char for _k in range(nout)])

To Reproduce
Steps to reproduce the behaviour:

  1. I have X - a numpy array shape (1774, 601) with float and nan values.
  2. I have y - a numpy array shape (1774, ) with int values 0 and 1 only.
  3. Just run: spearman_corr(X, y)

Expected behaviour
Returns the scores and doesn't fail.

Desktop (please complete the following information):

  • OS: MacOS 13.2.1 (22D68)

Proposed fix:
I solved the issue by simply adding
otypes=[X.dtype]

So line 567 from filters/univariate/measures.py is now:
ranks_X[:, i] = np.vectorize(d.get, otypes=[X.dtype])(X[:, i])

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