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

Example ¨Correcting from pandas.DataFrame as Data¨ needs a data transpose not to fail with shape not aligned #3

Closed
Jfortin1 opened this issue Aug 2, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Jfortin1
Copy link
Owner

Jfortin1 commented Aug 2, 2020

From @FinLouarn at ncullen93/neuroCombat#6

The first example ¨Correcting from Numpy Array as Data¨ works smoothly,
but the second example ¨Correcting from pandas.DataFrame as Data¨ fails with the following error of shape not aligned, unless you feed neuroCombat with data.T in stead of data.

python 3.7.7
pandas 0.25.3

ValueError Traceback (most recent call last)
in
15 batch_col=batch_col,
16 discrete_cols=discrete_cols,
---> 17 continuous_cols=continuous_cols)

/neuroCombat/neuroCombat/neuroCombat.py in neuroCombat(data, covars, batch_col, discrete_cols, continuous_cols)
97 # standardize data across features
98 print('Standardizing data across features..')
---> 99 s_data, s_mean, v_pool = standardize_across_features(data, design, info_dict)
100
101 # fit L/S models and find priors

/neuroCombat/neuroCombat/neuroCombat.py in standardize_across_features(X, design, info_dict)
159 sample_per_batch = info_dict['sample_per_batch']
160
--> 161 B_hat = np.dot(np.dot(la.inv(np.dot(design.T, design)), design.T), X.T)
162 grand_mean = np.dot((sample_per_batch/ float(n_sample)).T, B_hat[:n_batch,:])
163 var_pooled = np.dot(((X - np.dot(design, B_hat).T)**2), np.ones((n_sample, 1)) / float(n_sample))

<array_function internals> in dot(*args, **kwargs)

ValueError: shapes (8,57) and (22283,57) not aligned: 57 (dim 1) != 22283 (dim 0)

@Jfortin1 Jfortin1 added the bug Something isn't working label Aug 2, 2020
@Jfortin1 Jfortin1 self-assigned this Aug 2, 2020
@Jfortin1
Copy link
Owner Author

Jfortin1 commented Aug 2, 2020

@FinLouarn [features, samples] is indeed the required format for our latest release (0.2.7), for both a numpy array or pandas DataFrame.

@Jfortin1 Jfortin1 closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant