class_docstr: Rotate data for transfer learning.
  
  Rotate the data points from each source domain so to match its class means
  with those from the target domain. The loss function for this matching was
  first proposed in [1]_ and the optimization procedure for mininimizing it
  follows the presentation from [2]_.
  
  .. note::
     The data points from each domain must have been re-centered to the
     identity before calculating the rotation.
  
  .. note::
     Using .fit() and then .transform() will give different results than
     .fit_transform(). In fact, .fit_transform() should be applied on the
     training dataset (target and source) and .transform() on the test
     partition of the target dataset.
  
  Parameters
  ----------
  target_domain : str
      Domain to consider as target.
  weights : None | array, shape (n_classes,), default=None
      Weights to assign for each class. If None, then give the same weight
      for each class.
  metric : {'euclid', 'riemann'}, default='euclid'
      Metric for the distance to minimize between class means. Options are
      either the Euclidean ('euclid') or Riemannian ('riemann') distance.
  n_jobs : int, default=1
      The number of jobs to use for the computation. This works by computing
      the rotation matrix for each source domain in parallel. If -1 all CPUs
      are used.
  
  Attributes
  ----------
  rotations_ : dict
      Dictionary with key=domain_name and value=domain_rotation_matrix.
  
  References
  ----------
  .. [1] `Riemannian Procrustes analysis: transfer learning for
      brain-computer interfaces
      <https://hal.archives-ouvertes.fr/hal-01971856>`_
      PLC Rodrigues et al, IEEE Transactions on Biomedical Engineering,
      vol. 66, no. 8, pp. 2390-2401, December, 2018
  .. [2] `An introduction to optimization on smooth manifolds
      <https://www.nicolasboumal.net/book/>`_
      N. Boumal. To appear with Cambridge University Press. June, 2022
  
  Notes
  -----
  .. versionadded:: 0.4
class_docstr_tok: ["Rotate","data","for","transfer","learning",".","Rotate","the","data","points","from","each","source","domain","so","to","match","its","class","means","with","those","from","the","target","domain",".","The","loss","function","for","this","matching","was","first","proposed","in","[","1","]","_","and","the","optimization","procedure","for","mininimizing","it","follows","the","presentation","from","[","2","]","_",".","..","note",":",":","The","data","points","from","each","domain","must","have","been","re-centered","to","the","identity","before","calculating","the","rotation",".","..","note",":",":","Using",".fit","(",")","and","then",".transform","(",")","will","give","different","results","than",".fit_transform","(",")",".","In","fact",",",".fit_transform","(",")","should","be","applied","on","the","training","dataset","(","target","and","source",")","and",".transform","(",")","on","the","test","partition","of","the","target","dataset",".","Parameters","--","--","--","--","--","target_domain",":","str","Domain","to","consider","as","target",".","weights",":","None","|","array",",","shape","(","n_classes",",",")",",","default=None","Weights","to","assign","for","each","class",".","If","None",",","then","give","the","same","weight","for","each","class",".","metric",":","{","'euclid","'",",","'riemann","'","}",",","default='euclid'","Metric","for","the","distance","to","minimize","between","class","means",".","Options","are","either","the","Euclidean","(","'euclid","'",")","or","Riemannian","(","'riemann","'",")","distance",".","n_jobs",":","int",",","default=1","The","number","of","jobs","to","use","for","the","computation",".","This","works","by","computing","the","rotation","matrix","for","each","source","domain","in","parallel",".","If","-1","all","CPUs","are","used",".","Attributes","--","--","--","--","--","rotations_",":","dict","Dictionary","with","key=domain_name","and","value=domain_rotation_matrix",".","References","--","--","--","--","--","..","[","1","]","`","Riemannian","Procrustes","analysis",":","transfer","learning","for","brain-computer","interfaces","<","https",":","\/\/hal.archives-ouvertes.fr\/hal-01971856",">","`","_","PLC","Rodrigues","et","al",",","IEEE","Transactions","on","Biomedical","Engineering",",","vol",".","66",",","no",".","8",",","pp",".","2390-2401",",","December",",","2018","..","[","2","]","`","An","introduction","to","optimization","on","smooth","manifolds","<","https",":","\/\/www.nicolasboumal.net\/book\/",">","`","_","N.","Boumal",".","To","appear","with","Cambridge","University","Press",".","June",",","2022","Notes","--","--","-","..","versionadded",":",":","0.4"]
docstr: Init
docstr_tok: ["Init"]
code: def __init__(
      self, target_domain, weights=None, metric="euclid", n_jobs=1
  ):
      """Init"""
      self.target_domain = target_domain
      self.weights = weights
      self.metric = metric
      self.n_jobs = n_jobs
  
imports: import numpy
  from joblib import Parallel, delayed
  from sklearn.base import BaseEstimator, TransformerMixin, is_classifier, is_regressor
  from sklearn.pipeline import Pipeline
  from sklearn.metrics import accuracy_score, r2_score
  from ..utils.mean import mean_covariance, mean_riemann
  from ..utils.distance import distance
  from ..utils.base import invsqrtm, powm, sqrtm
  from ..utils.geodesic import geodesic
  from ..utils.utils import check_weights
  from ._rotate import _get_rotation_matrix
  from ..classification import MDM, _check_metric
  from ..preprocessing import Whitening
  from ._tools import decode_domains
label_desc: Use image node_id 1 to create a new TLRotate object from inherited base classes: BaseEstimator, TransformerMixin with example: obj = TLRotate(target_domain, weights, metric, n_jobs)