Comments (7)
Apologies for never having responded! Must have caught me at a busy time. Not done anything myself, as ever welcome any contributions that are of practical use to people :)
from cca_zoo.
Implementation in Python:
# compute the absolute correlation matrix between the original and resampled
# v weights
def cor_matrix(X,Y):
X = (X - X.mean(axis=0)) / X.std(axis=0)
Y = (Y - Y.mean(axis=0)) / Y.std(axis=0)
cor_matrix = np.dot(X.T, Y) / X.shape[0]
return cor_matrix
def reorderCCA(v_org,v_res,u_org,u_res,cors_org,cors_res):
cor_matrix_abs = np.abs(cor_matrix(v_org,v_res))
res_match = np.argmax(cor_matrix_abs,axis=1)
res_cor = np.amax(cor_matrix_abs,axis=1)
res_match_count = len(np.unique(res_match))
# now reorder the u and v weights from the resampled CCA based on the correlation matches
u_res_ordered = u_res[:,res_match]
v_res_ordered = v_res[:,res_match]
cors_final = cors_res[res_match]
# for each v variate get the 'mean' sign for both original and resampled v
signs_org = np.sign(np.mean(np.sign(v_org),axis=0))
signs_res = np.sign(np.mean(np.sign(v_res_ordered),axis=0))
# compute element wise product
signs_prod = (signs_org * signs_res).reshape(-1,1)
# change the signs of u and v of the resampled cca
u_final = (u_res_ordered.T * signs_prod).T
v_final = (v_res_ordered.T * signs_prod).T
# if you can't exclusively assign one resampled v to one original v, return
# nans
if res_match_count < u_org.shape[1]:
u_na = np.empty(u_org.shape)
u_na[:] = np.nan
v_na = np.empty(v_org.shape)
v_na[:] = np.nan
cors_na = np.repeat(np.nan,u_org.shape[1])
res_match_na = np.repeat(np.nan,u_org.shape[1])
res_cor_na = np.repeat(np.nan,u_org.shape[1])
res_one_reorder = [u_na,v_na,cors_na,res_match_na,res_cor_na]
else:
res_one_reorder = [u_final,v_final,cors_final,res_match,res_cor]
return res_one_reorder
from cca_zoo.
I am not sure if this function makes sense. Xia et al. refer to this paper (Miลกiฤ et al.)
Matching Decompositions From Original and Resampled Matrices
The decompositions of both permuted and bootstrap-resampled
data matrices are not guaranteed to produce a set of LVs comparable with the ones derived from the original data matrix, because
both types of resampling could induce arbitrary axis rotation (a
change in the order of LVs) or axis reflection (a sign change for
the weights). As a result, Procrustes rotations are used to match
the resampled LVs to the original LVs (McIntosh and Lobaugh
2004).
But here Procrustes Rotations are used to match resampled to original variates. I am not sure if the function above from Xia et al. is Procrustes Rotation?
from cca_zoo.
I guess the whole issue could also be renamed to: "Implement Procrustes Rotation for resampling purposes (bootstrapping, permutation)".
For completeness:
Here's the implementation from pyls:
https://github.com/netneurolab/pypyls/blob/d8a19d564cc5804249527b68c937df3a5fd8c7cc/pyls/compute.py#L240
This package might help:
https://procrustes.readthedocs.io/en/latest/
Maybe also this:
https://github.com/MaxHalford/prince#generalized-procrustes-analysis-gpa
from cca_zoo.
Any update on this? I might start to work on this with my colleagues on this :)
Also posted a question on this on CrossValidated
from cca_zoo.
Spent some time making sure everything works with scikit-learn permutation testing stuff so that might be relevant/helpful
from cca_zoo.
In a nutshell: If we are only considering one variate, we can simply take the absolute values of the loadings/weights. But once you got more variates, you may end up in situations where you have a different order of the variates but still similar weights (similar relationship of variables when only considering each variate in isolation). In this case, Procrustes rotation may help. Not sure, however, what some statisticians would say about this because a different order of variates might inherently also be an indicator of bad reliability.
from cca_zoo.
Related Issues (20)
- GRCCA gives quite different results with original implementation HOT 9
- The cca loss of two irrelevant dataset is -20. HOT 13
- The DCCA loss of two equal view is -6 (dim=100). HOT 12
- when run "python plot_dcca.py" error occurs HOT 2
- problem of latent_dims setting of DCCA_EigenGame HOT 9
- the problem of the model.transform() HOT 4
- Problems encountered when using DCCA.fit
- Pass down parameters to BaseSearchCV in cca_zoo.model_selection.GridSearchCV
- the value of the model.fit_transform() is nan HOT 7
- Could you provide a 3-group CCA method? HOT 2
- What happened to the scale argument? HOT 19
- Cannot simulate data HOT 2
- TerminatedWorkerError when using GridSearchCV HOT 29
- Do you have a CCA method incorporated with Multivariate Granger causality? HOT 3
- cca_zoo.model_selection.GridSearchCV's param_grid parameter should accept any type of iterator HOT 3
- Implement CCA-classes that can account for sample groups HOT 2
- predict() method for models? HOT 6
- SPLS is slower than it used to be.
- Installation error HOT 14
- The algorithm failed to converge because the input matrix is ill-conditioned or has too many repeated eigenvalues (error code: 1). HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cca_zoo.