class_docstr: Class AAC for Generalized Geodesic Principal Components (GGPCA) on Graph Space.
  
  The Align All and Compute (AAC) algorithm for GGPCA estimation is
  introduced in [Calissano2020]_ and it estimates the GGPCA for a set of
  labeled or unlabeled graphs. The idea is to optimally aligned the graphs to the
  current GGPCA estimator using the optimal alignment between the graphs and the
  geodesics and then compute the GGPCA estimation between the aligned adjacency
  matrices (the PCA in the euclidean space of dimension :math:`nodes \times nodes`).
  The algorithm stops as soon as the percentage of variance explained by PCA in two
  consecutive estimations is lower then :math:`\epsilon` or the maximum number of
  iteration is reached. The initialization step consists in aligning all the data with
  respect to an initial point.
  
  Parameters
  ----------
  metric : GraphSpaceMetric
      Metric Class on Graph Space.
  epsilon: float, default=1e-6
      Stopping criterion for the estimation step, i.e., the distance between two
      consecutive estimators.
  max_iter: int, default = 20
      Stopping criterion on the maximum number of iterations.
  init_point: array-like, shape=[n_nodes, n_nodes] or GraphPoint, default random.
      Algorithm initialization.
  n_components: int
      Number of principal components to be estimated. Notice that the convergence is
      ensured only for the first principal component.
  save_last_X: bool, default = True
      Flag to save the data as aligned in the last algorithm iteration.
  
  Attributes
  ----------
  total_space_estimator: BaseEstimator
      Method for the estimation of the PCA for a set of flattened adjacency matrices
      in the total space. Check geomstats.learning._sklearn_wrapper for details.
      Default: ``sklearn.decomposition.PCA``.
  n_iter_ : int
      Number of performed iterations.
  aligned_X_: array-like, shape=[n_samples, n_nodes, n_nodes] or set of GraphPoint.
      Set of aligned data as after the last call of fit.
      Saved if ``save_last_X is True``.
  
  References
  ----------
  .. [Calissano2020]  Calissano, A., Feragen, A., Vantini, S.
      “Graph Space: Geodesic Principal Components for a Population of
      Network-valued Data.” Mox report 14, 2020.
      https://mox.polimi.it/reports-and-theses/publication-results/?id=855.
class_docstr_tok: ["Class","AAC","for","Generalized","Geodesic","Principal","Components","(","GGPCA",")","on","Graph","Space",".","The","Align","All","and","Compute","(","AAC",")","algorithm","for","GGPCA","estimation","is","introduced","in","[","Calissano2020","]","_","and","it","estimates","the","GGPCA","for","a","set","of","labeled","or","unlabeled","graphs",".","The","idea","is","to","optimally","aligned","the","graphs","to","the","current","GGPCA","estimator","using","the","optimal","alignment","between","the","graphs","and","the","geodesics","and","then","compute","the","GGPCA","estimation","between","the","aligned","adjacency","matrices","(","the","PCA","in","the","euclidean","space","of","dimension",":","math",":","`","nodes","\\times","nodes","`",")",".","The","algorithm","stops","as","soon","as","the","percentage","of","variance","explained","by","PCA","in","two","consecutive","estimations","is","lower","then",":","math",":","`","\\epsilon","`","or","the","maximum","number","of","iteration","is","reached",".","The","initialization","step","consists","in","aligning","all","the","data","with","respect","to","an","initial","point",".","Parameters","--","--","--","--","--","metric",":","GraphSpaceMetric","Metric","Class","on","Graph","Space",".","epsilon",":","float",",","default=1e-6","Stopping","criterion","for","the","estimation","step",",","i.e.",",","the","distance","between","two","consecutive","estimators",".","max_iter",":","int",",","default","=","20","Stopping","criterion","on","the","maximum","number","of","iterations",".","init_point",":","array-like",",","shape=","[","n_nodes",",","n_nodes","]","or","GraphPoint",",","default","random",".","Algorithm","initialization",".","n_components",":","int","Number","of","principal","components","to","be","estimated",".","Notice","that","the","convergence","is","ensured","only","for","the","first","principal","component",".","save_last_X",":","bool",",","default","=","True","Flag","to","save","the","data","as","aligned","in","the","last","algorithm","iteration",".","Attributes","--","--","--","--","--","total_space_estimator",":","BaseEstimator","Method","for","the","estimation","of","the","PCA","for","a","set","of","flattened","adjacency","matrices","in","the","total","space",".","Check","geomstats.learning._sklearn_wrapper","for","details",".","Default",":","``","sklearn.decomposition.PCA","``",".","n_iter_",":","int","Number","of","performed","iterations",".","aligned_X_",":","array-like",",","shape=","[","n_samples",",","n_nodes",",","n_nodes","]","or","set","of","GraphPoint",".","Set","of","aligned","data","as","after","the","last","call","of","fit",".","Saved","if","``","save_last_X","is","True","``",".","References","--","--","--","--","--","..","[","Calissano2020","]","Calissano",",","A.",",","Feragen",",","A.",",","Vantini",",","S.","\u201c","Graph","Space",":","Geodesic","Principal","Components","for","a","Population","of","Network-valued","Data.","\u201d","Mox","report","14",",","2020.","https",":","\/\/mox.polimi.it\/reports-and-theses\/publication-results\/","?","id=855","."]
docstr: Fit the GGPCA.
  
  Parameters
  ----------
  X : array-like, shape=[n_samples, n_nodes, n_nodes] or set of GraphPoint.
      Dataset to estimate the GGPCA.
  y : Ignored
      Ignored.
  
  Returns
  -------
  self : object
      Returns self.
  
  Note: Default method in the total space is sklearn.decomposition.PCA where
  the input data are centered but not scaled for each feature.
docstr_tok: ["Fit","the","GGPCA",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape=","[","n_samples",",","n_nodes",",","n_nodes","]","or","set","of","GraphPoint",".","Dataset","to","estimate","the","GGPCA",".","y",":","Ignored","Ignored",".","Returns","--","--","--","-","self",":","object","Returns","self",".","Note",":","Default","method","in","the","total","space","is","sklearn.decomposition.PCA","where","the","input","data","are","centered","but","not","scaled","for","each","feature","."]
code: def fit(self, X, y=None):
      """Fit the GGPCA.
  
      Parameters
      ----------
      X : array-like, shape=[n_samples, n_nodes, n_nodes] or set of GraphPoint.
          Dataset to estimate the GGPCA.
      y : Ignored
          Ignored.
  
      Returns
      -------
      self : object
          Returns self.
  
      Note: Default method in the total space is sklearn.decomposition.PCA where
      the input data are centered but not scaled for each feature.
      """
      x = (
          random.choice(X)
          if self.init_point is None
          else self.init_point
      )
      aligned_X = self.metric.align_point_to_point(x, X)
  
      self.total_space_estimator.fit(aligned_X)
      previous_expl = (
          self.total_space_estimator.explained_variance_ratio_[0]
      )
  
      error = self.epsilon + 1
      iteration = 0
      while error > self.epsilon and iteration < self.max_iter:
          iteration += 1
          mean = self.total_space_estimator.reshaped_mean_
          direc = self.total_space_estimator.reshaped_components_[0]
  
          geodesic = self.metric.total_space_metric.geodesic(
              initial_point=mean, initial_tangent_vec=direc
          )
  
          aligned_X = self.metric.align_point_to_geodesic(
              geodesic, aligned_X
          )
          self.total_space_estimator.fit(aligned_X)
          expl_ = self.total_space_estimator.explained_variance_ratio_[
              0
          ]
  
          error = expl_ - previous_expl
          previous_expl = expl_
  
      if self.save_last_X:
          self.aligned_X_ = aligned_X
      self.n_iter_ = iteration
      _warn_max_iterations(iteration, self.max_iter)
  
      return self
  
imports: import logging
  import random
  from sklearn.base import BaseEstimator
  import geomstats.backend
  from geomstats.errors import check_parameter_accepted_values
  from geomstats.learning._sklearn_wrapper import WrappedLinearRegression, WrappedPCA
  from geomstats.learning.frechet_mean import FrechetMean
label_desc: Use image node_id 6 for calling the _AACGGPCA obj's underlying member method code with example usage: obj.fit(X, y) and returns: self