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

ValueError: Input contains NaN, infinity or a value too large for dtype('float64'). #19

Closed
KingArnaiz opened this issue Apr 28, 2022 · 4 comments

Comments

@KingArnaiz
Copy link

  • confounds version:0.1.3
  • Python version: 3.10
  • Operating System: mac

Having the error eventhough the data is clean, has no Na nor NaN values

C_sample = graph_corr_1[confound_cols]
X_sample = graph_corr_1.drop(confound_cols, axis=1)

resid = Residualize()
resid.fit(C_sample)
graph_corr_2 = resid.transform(C_sample)

@KingArnaiz
Copy link
Author


ValueError Traceback (most recent call last)
in
14
15 resid = Residualize()
---> 16 resid.fit(C_sample)
17 graph_corr_2 = resid.transform(C_sample)

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/confounds/base.py in fit(self, X, y)
210 """
211
--> 212 return self._fit(X, y) # which itself must return self
213
214

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/confounds/base.py in _fit(self, in_features, confounds)
217
218 in_features = check_array(in_features)
--> 219 confounds = check_array(confounds, ensure_2d=False)
220
221 # turning it into 2D, in case if its just a column

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/utils/validation.py in inner_f(*args, **kwargs)
61 extra_args = len(args) - len(all_args)
62 if extra_args <= 0:
---> 63 return f(*args, **kwargs)
64
65 # extra_args > 0

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
661
662 if force_all_finite:
--> 663 _assert_all_finite(array,
664 allow_nan=force_all_finite == 'allow-nan')
665

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/utils/validation.py in _assert_all_finite(X, allow_nan, msg_dtype)
101 not allow_nan and not np.isfinite(X).all()):
102 type_err = 'infinity' if allow_nan else 'NaN, infinity'
--> 103 raise ValueError(
104 msg_err.format
105 (type_err,

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

@raamana
Copy link
Owner

raamana commented Apr 28, 2022

thanks @KingArnaiz for trying to use the confounds the package - it appears you are not using it correctly. the resid.fit() requires two inputs: data X and confound variables C, so try resid.fit(X_sample, C_sample)? The same thing applies to .transform() method: resid.transform(X_test, C_test)

@raamana
Copy link
Owner

raamana commented Apr 29, 2022

let me know if that works for you or not?

if it doesn't, try it with some simulated data (not your own real data) first, and see how it goes? and share the output and logs.

@KingArnaiz
Copy link
Author

It worked. Thanks

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