class_docstr: CP tensor regression
  
  Learns a low rank CP tensor weight, This performs a partial least square regression to a tensor X (>= 2 modes)
  against a matrix Y. The first modes of X and Y will be considered coupled, and the decomposition will maximize
  the covariance between them.
  
  Parameters
  ----------
  n_components : int
      rank of the CP decomposition of the regression weights
  tol : float
      convergence value
  n_iter_max : int, optional, default is 100
      maximum number of iteration
  random_state : None, int or RandomState, optional, default is None
  verbose : bool, default is False
      whether to be verbose during fitting
  
  References
  ----------
  .. [1] Rasmus Bro, "Multiway calibration. Multilinear PLS", Chemometrics, 1996
class_docstr_tok: ["CP","tensor","regression","Learns","a","low","rank","CP","tensor","weight",",","This","performs","a","partial","least","square","regression","to","a","tensor","X","(",">","=","2","modes",")","against","a","matrix","Y",".","The","first","modes","of","X","and","Y","will","be","considered","coupled",",","and","the","decomposition","will","maximize","the","covariance","between","them",".","Parameters","--","--","--","--","--","n_components",":","int","rank","of","the","CP","decomposition","of","the","regression","weights","tol",":","float","convergence","value","n_iter_max",":","int",",","optional",",","default","is","100","maximum","number","of","iteration","random_state",":","None",",","int","or","RandomState",",","optional",",","default","is","None","verbose",":","bool",",","default","is","False","whether","to","be","verbose","during","fitting","References","--","--","--","--","--","..","[","1","]","Rasmus","Bro",",","``","Multiway","calibration",".","Multilinear","PLS","''",",","Chemometrics",",","1996"]
docstr: Returns the predicted labels for a new data tensor
  
  Parameters
  ----------
  X : ndarray
      tensor data of shape (n_samples, N1, ..., NS)
docstr_tok: ["Returns","the","predicted","labels","for","a","new","data","tensor","Parameters","--","--","--","--","--","X",":","ndarray","tensor","data","of","shape","(","n_samples",",","N1",",","...",",","NS",")"]
code: def predict(self, X):
      """Returns the predicted labels for a new data tensor
  
      Parameters
      ----------
      X : ndarray
          tensor data of shape (n_samples, N1, ..., NS)
      """
      if self.X_shape_[1:] != T.shape(X)[1:]:
          raise ValueError(
              f"Training X has shape {self.X_shape_}, while the new X has shape {T.shape(X)}"
          )
      X = T.copy(X)
      X -= self.X_mean_
      X_projection = T.zeros(
          (T.shape(X)[0], self.n_components), **T.context(X)
      )
      for component in range(self.n_components):
          X_projection = T.index_update(
              X_projection,
              T.index[:, component],
              multi_mode_dot(
                  X,
                  [
                      factor[:, component]
                      for factor in self.X_factors[1:]
                  ],
                  range(1, T.ndim(X)),
              ),
          )
          X -= outer(
              [X_projection[:, component]]
              + [factor[:, component] for factor in self.X_factors[1:]],
          )
  
      return (
          T.dot(
              T.dot(X_projection, self.coef_),
              T.transpose(self.Y_factors[1]),
          )
          + self.Y_mean_
      )
  
file_path: tensorly/tensorly/regression/cp_plsr.py
imports: from ..tenalg import multi_mode_dot, outer
  from ..None import backend
  from ..None import tensor_to_vec
  from ..decomposition._cp import initialize_cp
label_desc: Use image node_id 5 for calling the CP_PLSR obj's underlying member method code with example usage: obj.predict(X) and returns: unknown