Canonical correlation analysis in Python with sklearn

I am trying to use sklearn to perform canonical correlation analysis (CCA). I start with a simple example that is included in the manual :

from sklearn.cross_decomposition import CCA X = [[0., 0., 1.], [1.,0.,0.], [2.,2.,2.], [3.,5.,4.]] Y = [[0.1, -0.2], [0.9, 1.1], [6.2, 5.9], [11.9, 12.3]] cca = CCA(n_components=1) cca.fit(X, Y) X_c, Y_c = cca.transform(X, Y) 

I understand that in cca.x_weights_ I get "canonical coefficients", i.e. linear combinations of the original X variables (columns of the matrices "A" and "B" returned by MATLAB ). However, where are the "canonical correlations", i.e. The maximum correlation achieved by applying the transformation specified by the canonical coefficients (ie, the Vector "r" returned by MATLAB). Is it also possible to get this in Python?

+5
source share

Source: https://habr.com/ru/post/1204414/


All Articles