class_docstr: Generalized Procrustes Analysis (GPA).
  
  Algorithm outline:
  
  1. Choose a reference shape.
  2. Apply Procrustes Analysis to superimpose all shapes to the reference shape.
  3. Compute the mean shape of the superimposed shapes.
  4. Repeat steps 2 and 3 until convergence.
  
  Parameters
  ----------
  max_iter
      The maximum number of Procrustes analysis iterations.
  tol
      The tolerance for the optimization; stops if the Procrustes distance decreases by less or
      equal to `tol` between iterations.
  init
      Method for initializing reference shape.
      - 'random' : choose reference shape from shape list
      - 'mean' : initialize reference shape as mean of shape list
  scale
      Whether to compute transformations with a scale component.
  copy
      Whether to copy data or perform the computations inplace. If False, data passed to fit are
      overwritten and running fit(X).transform(X) will not yield the expected results,
      use fit_transform(X) instead.
  check_input
      Whether to check the consistency of the inputs.
  random_state
      Determines random number generation for initialization when `init=='random'`.
  
  References
  ----------
  https://wikipedia.org/wiki/Generalized_Procrustes_analysis
  https://medium.com/@olga_kravchenko/generalized-procrustes-analysis-with-python-numpy-c571e8e8a421
class_docstr_tok: ["Generalized","Procrustes","Analysis","(","GPA",")",".","Algorithm","outline",":","1",".","Choose","a","reference","shape",".","2",".","Apply","Procrustes","Analysis","to","superimpose","all","shapes","to","the","reference","shape",".","3",".","Compute","the","mean","shape","of","the","superimposed","shapes",".","4",".","Repeat","steps","2","and","3","until","convergence",".","Parameters","--","--","--","--","--","max_iter","The","maximum","number","of","Procrustes","analysis","iterations",".","tol","The","tolerance","for","the","optimization",";","stops","if","the","Procrustes","distance","decreases","by","less","or","equal","to","`","tol","`","between","iterations",".","init","Method","for","initializing","reference","shape",".","-","'random","'",":","choose","reference","shape","from","shape","list","-","'mean","'",":","initialize","reference","shape","as","mean","of","shape","list","scale","Whether","to","compute","transformations","with","a","scale","component",".","copy","Whether","to","copy","data","or","perform","the","computations","inplace",".","If","False",",","data","passed","to","fit","are","overwritten","and","running","fit","(","X",")",".transform","(","X",")","will","not","yield","the","expected","results",",","use","fit_transform","(","X",")","instead",".","check_input","Whether","to","check","the","consistency","of","the","inputs",".","random_state","Determines","random","number","generation","for","initialization","when","`","init=='random","'","`",".","References","--","--","--","--","--","https",":","\/\/wikipedia.org\/wiki\/Generalized_Procrustes_analysis","https",":","\/\/medium.com\/","@","olga_kravchenko\/generalized-procrustes-analysis-with-python-numpy-c571e8e8a421"]
docstr: Fit the model with X and return the aligned shapes.
  
  Parameters:
      X (array-like of shape (n_shapes, n_points, n_dim)): Matrix of
          shapes to match to each other.
      y: Ignored
  
  Returns:
      X_new (array-like of shape (n_shapes, n_points, n_dim)): Matrix X
          of aligned shapes
docstr_tok: ["Fit","the","model","with","X","and","return","the","aligned","shapes",".","Parameters",":","X","(","array-like","of","shape","(","n_shapes",",","n_points",",","n_dim",")",")",":","Matrix","of","shapes","to","match","to","each","other",".","y",":","Ignored","Returns",":","X_new","(","array-like","of","shape","(","n_shapes",",","n_points",",","n_dim",")",")",":","Matrix","X","of","aligned","shapes"]
code: def fit_transform(self, X, y=None):
      """Fit the model with X and return the aligned shapes.
  
      Parameters:
          X (array-like of shape (n_shapes, n_points, n_dim)): Matrix of
              shapes to match to each other.
          y: Ignored
  
      Returns:
          X_new (array-like of shape (n_shapes, n_points, n_dim)): Matrix X
              of aligned shapes
      """
  
      # Check input
      if self.check_input:
          self._check_input(X)
  
      # Copy data
      if self.copy:
          X = np.array(X, copy=True)
  
      # scikit-learn SLEP010
      n_shapes, n_points, n_dim = X.shape
      self.n_features_in_ = n_dim
  
      # Pick reference shape
      if self.init == "random":
          random_state = sk_utils.check_random_state(self.random_state)
          ref_shape_idx = random_state.randint(X.shape[0])
          reference_shape = X[ref_shape_idx].copy()
      elif self.init == "mean":
          reference_shape = X.mean(axis=0)
      else:
          raise ValueError(
              "init method must be one of ('random', 'mean')"
          )
  
      for iter_idx in range(self.max_iter):
          # Align each shape to reference shape
          for shape_idx in range(X.shape[0]):
              if self.scale:
                  _, X[shape_idx], _ = procrustes(
                      reference_shape, X[shape_idx]
                  )
              else:
                  _, X[shape_idx] = unscaled_procrustes(
                      reference_shape, X[shape_idx]
                  )
  
          # Compute diagnostics
          mean_shape = X.mean(axis=0)
          procrustes_distance = np.linalg.norm(
              reference_shape - mean_shape
          )
  
          # Update reference shape
          reference_shape = mean_shape
  
          # Check for convergence
          if procrustes_distance <= self.tol:
              break
  
      # Store properties
      self._reference_shape = reference_shape
  
      # Return the aligned shapes
      return X
  
file_path: prince/prince/gpa.py
imports: from __future__ import annotations
  import numpy
  from scipy.linalg import orthogonal_procrustes
  from scipy.spatial import procrustes
  from sklearn import base
  from sklearn import utils
  from prince import utils
label_desc: Use image node_id 4 for calling the GPA obj's underlying member method code with example usage: obj.fit_transform(X, y) and returns: X