class_docstr: Partial Least Squares (PLS)
  
  This class implements the generic PLS algorithm, constructors' parameters
  allow to obtain a specific implementation such as:
  
  - PLS2 regression, i.e., PLS 2 blocks, mode A, with asymmetric deflation
    and unnormalized y weights such as defined by [Tenenhaus 1998] p. 132.
    With univariate response it implements PLS1.
  
  - PLS canonical, i.e., PLS 2 blocks, mode A, with symmetric deflation and
    normalized y weights such as defined by [Tenenhaus 1998] (p. 132) and
    [Wegelin et al. 2000]. This parametrization implements the original Wold
    algorithm.
  
  We use the terminology defined by [Wegelin et al. 2000].
  This implementation uses the PLS Wold 2 blocks algorithm based on two
  nested loops:
      (i) The outer loop iterate over components.
      (ii) The inner loop estimates the weights vectors. This can be done
      with two algo. (a) the inner loop of the original NIPALS algo. or (b) a
      SVD on residuals cross-covariance matrices.
  
  n_components : int, number of components to keep. (default 2).
  
  scale : boolean, scale data? (default True)
  
  deflation_mode : str, "canonical" or "regression". See notes.
  
  mode : "A" classical PLS and "B" CCA. See notes.
  
  norm_y_weights: boolean, normalize Y weights to one? (default False)
  
  algorithm : string, "nipals" or "svd"
      The algorithm used to estimate the weights. It will be called
      n_components times, i.e. once for each iteration of the outer loop.
  
  max_iter : an integer, the maximum number of iterations (default 500)
      of the NIPALS inner loop (used only if algorithm="nipals")
  
  tol : non-negative real, default 1e-06
      The tolerance used in the iterative algorithm.
  
  copy : boolean, default True
      Whether the deflation should be done on a copy. Let the default
      value to True unless you don't care about side effects.
  
  Attributes
  ----------
  x_weights_ : array, [p, n_components]
      X block weights vectors.
  
  y_weights_ : array, [q, n_components]
      Y block weights vectors.
  
  x_loadings_ : array, [p, n_components]
      X block loadings vectors.
  
  y_loadings_ : array, [q, n_components]
      Y block loadings vectors.
  
  x_scores_ : array, [n_samples, n_components]
      X scores.
  
  y_scores_ : array, [n_samples, n_components]
      Y scores.
  
  x_rotations_ : array, [p, n_components]
      X block to latents rotations.
  
  y_rotations_ : array, [q, n_components]
      Y block to latents rotations.
  
  coef_: array, [p, q]
      The coefficients of the linear model: ``Y = X coef_ + Err``
  
  n_iter_ : array-like
      Number of iterations of the NIPALS inner loop for each
      component. Not useful if the algorithm given is "svd".
  
  References
  ----------
  
  Jacob A. Wegelin. A survey of Partial Least Squares (PLS) methods, with
  emphasis on the two-block case. Technical Report 371, Department of
  Statistics, University of Washington, Seattle, 2000.
  
  In French but still a reference:
  Tenenhaus, M. (1998). La regression PLS: theorie et pratique. Paris:
  Editions Technic.
  
  See also
  --------
  PLSCanonical
  PLSRegression
  CCA
  PLS_SVD
docstr: Learn and apply the dimension reduction on the train data.
  
  Parameters
  ----------
  X : array-like of predictors, shape = [n_samples, p]
      Training vectors, where n_samples in the number of samples and
      p is the number of predictors.
  
  Y : array-like of response, shape = [n_samples, q], optional
      Training vectors, where n_samples in the number of samples and
      q is the number of response variables.
  
  copy : boolean, default True
      Whether to copy X and Y, or perform in-place normalization.
  
  Returns
  -------
  x_scores if Y is not given, (x_scores, y_scores) otherwise.
docstr_tok: ["Learn","and","apply","the","dimension","reduction","on","the","train","data",".","Parameters","--","--","--","--","--","X",":","array-like","of","predictors",",","shape","=","[","n_samples",",","p","]","Training","vectors",",","where","n_samples","in","the","number","of","samples","and","p","is","the","number","of","predictors",".","Y",":","array-like","of","response",",","shape","=","[","n_samples",",","q","]",",","optional","Training","vectors",",","where","n_samples","in","the","number","of","samples","and","q","is","the","number","of","response","variables",".","copy",":","boolean",",","default","True","Whether","to","copy","X","and","Y",",","or","perform","in-place","normalization",".","Returns","--","--","--","-","x_scores","if","Y","is","not","given",",","(","x_scores",",","y_scores",")","otherwise","."]
code: def fit_transform(self, X, y=None, **fit_params):
      """Learn and apply the dimension reduction on the train data.
  
      Parameters
      ----------
      X : array-like of predictors, shape = [n_samples, p]
          Training vectors, where n_samples in the number of samples and
          p is the number of predictors.
  
      Y : array-like of response, shape = [n_samples, q], optional
          Training vectors, where n_samples in the number of samples and
          q is the number of response variables.
  
      copy : boolean, default True
          Whether to copy X and Y, or perform in-place normalization.
  
      Returns
      -------
      x_scores if Y is not given, (x_scores, y_scores) otherwise.
      """
      return self.fit(X, y, **fit_params).transform(X, y)
  
imports: from distutils.version import LooseVersion
  from sklearn.utils.extmath import svd_flip
  from ..base import BaseEstimator, RegressorMixin, TransformerMixin
  from ..utils import check_array, check_consistent_length
  from ..externals import six
  import warnings
  from abc import ABCMeta, abstractmethod
  import numpy
  from scipy import linalg
  from ..utils import arpack
  from ..utils.validation import check_is_fitted, FLOAT_DTYPES
  import scipy
label_desc: Use image node_id 5 for calling the _PLS obj's underlying member method code with example usage: obj.fit_transform(X, y) and returns: self