Simple usage of various cross decomposition algorithms:
PLSCanonical
PLSRegression, with multivariate response, a.k.a. PLS2
PLSRegression, with univariate response, a.k.a. PLS1
CCA
Given 2 multivariate covarying two-dimensional datasets, X, and Y,
PLS extracts the ‘directions of covariance’, i.e. the components of each
datasets that explain the most shared variance between both datasets.
This is apparent on the scatterplot matrix display: components 1 in
dataset X and dataset Y are maximally correlated (points lie around the
first diagonal). This is also true for components 2 in both dataset,
however, the correlation across datasets for different components is
weak: the point cloud is very spherical.
# Authors: The scikit-learn developers# SPDX-License-Identifier: BSD-3-Clause
PLS regression, with univariate response, a.k.a. PLS1
n=1000p=10X=rng.normal(size=(n,p))y=X[:,0]+2*X[:,1]+rng.normal(size=n)+5pls1=PLSRegression(n_components=3)pls1.fit(X,y)# note that the number of components exceeds 1 (the dimension of y)print("Estimated betas")print(np.round(pls1.coef_,1))