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

array must not contain infs or NaNs #182

Open
GengYuIsland opened this issue May 22, 2024 · 2 comments
Open

array must not contain infs or NaNs #182

GengYuIsland opened this issue May 22, 2024 · 2 comments

Comments

@GengYuIsland
Copy link

Hi, when I try to run this code, there is an error:

from causallearn.search.FCMBased import lingam
model = lingam.ICALiNGAM()
model.fit(data)

from causallearn.search.FCMBased.lingam.utils import make_dot
make_dot(model.adjacency_matrix_, labels=labels)

error:

C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\decomposition\_fastica.py:626: RuntimeWarning: invalid value encountered in divide
  K = (u / d).T[:n_components]  # see (6.33) p.140
Traceback (most recent call last):
  File "f:\causal.py", line 81, in <module>
    model.fit(data)
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\causallearn\search\FCMBased\lingam\ica_lingam.py", line 55, in fit
    ica.fit(X)
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\base.py", line 1474, in wrapper
    return fit_method(estimator, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\decomposition\_fastica.py", line 733, in fit
    self._fit_transform(X, compute_sources=False)
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\decomposition\_fastica.py", line 660, in _fit_transform
    W, n_iter = _ica_par(X1, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\decomposition\_fastica.py", line 118, in _ica_par
    W1 = _sym_decorrelation(np.dot(gwtx, X.T) / p_ - g_wtx[:, np.newaxis] * W)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\sklearn\decomposition\_fastica.py", line 61, in _sym_decorrelation
    s, u = linalg.eigh(np.dot(W, W.T))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\scipy\linalg\_decomp.py", line 460, in eigh
    a1 = _asarray_validated(a, check_finite=check_finite)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\scipy\_lib\_util.py", line 240, in _asarray_validated
    a = toarray(a)
        ^^^^^^^^^^
  File "C:\Users\.conda\envs\causalenv\Lib\site-packages\numpy\lib\function_base.py", line 630, in asarray_chkfinite
    raise ValueError(
ValueError: array must not contain infs or NaNs

I used my own dataset, and checked there was no infs and NaNs, can you help me to fix it up?

@kunwuz
Copy link
Collaborator

kunwuz commented Jun 9, 2024

Hi, could you please share a minimal data example? I tried some simulated data but haven't reproduced the error.

@GengYuIsland
Copy link
Author

Sorry I can't access my server at the moment, I'll add the data later. My data columns contain binary features, do these features cause the error above?

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