array must not contain infs or NaNs
GengYuIsland opened this issue · comments
有故事的耿同学 commented
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?
Yujia Zheng commented
Hi, could you please share a minimal data example? I tried some simulated data but haven't reproduced the error.
有故事的耿同学 commented
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?