class_docstr: Class AAC for Frechet Mean on Graph Space.
  
  The Align All and Compute (AAC) algorithm for Frechet Mean (FM)estimation is
  introduced in [Calissano2020]_ and it estimates the Frechet Mean for a set of
  labeled or unlabeled graphs. The idea is to optimally aligned the graphs to the
  current mean estimator using the optimal alignment between the graphs and the mean
  (graph matching between two graphs) and compute the mean estimation between the
  aligned adjacency matrices (the arithmetic mean in the euclidean space of dimension
  :math:`nodes \times nodes`). The algorithm stops as soon as the distance between two
  consecutive estimations is lower then :math:`\epsilon` or the maximum number of
  iterations is reached. The initialization step consists in aligning 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.
  save_last_X: bool, default = True
      Flag to save the data as aligned in the last algorithm iteration.
  total_space_estimator_kwargs : dict
      Total space estimator keyword arguments.
  
  Attributes
  ----------
  total_space_estimator : BaseEstimator
      Frechet mean estimator in total space.
  estimate_ : array-like, mean=[n_nodes, n_nodes]
      Mean.
  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","Frechet","Mean","on","Graph","Space",".","The","Align","All","and","Compute","(","AAC",")","algorithm","for","Frechet","Mean","(","FM",")","estimation","is","introduced","in","[","Calissano2020","]","_","and","it","estimates","the","Frechet","Mean","for","a","set","of","labeled","or","unlabeled","graphs",".","The","idea","is","to","optimally","aligned","the","graphs","to","the","current","mean","estimator","using","the","optimal","alignment","between","the","graphs","and","the","mean","(","graph","matching","between","two","graphs",")","and","compute","the","mean","estimation","between","the","aligned","adjacency","matrices","(","the","arithmetic","mean","in","the","euclidean","space","of","dimension",":","math",":","`","nodes","\\times","nodes","`",")",".","The","algorithm","stops","as","soon","as","the","distance","between","two","consecutive","estimations","is","lower","then",":","math",":","`","\\epsilon","`","or","the","maximum","number","of","iterations","is","reached",".","The","initialization","step","consists","in","aligning","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",".","save_last_X",":","bool",",","default","=","True","Flag","to","save","the","data","as","aligned","in","the","last","algorithm","iteration",".","total_space_estimator_kwargs",":","dict","Total","space","estimator","keyword","arguments",".","Attributes","--","--","--","--","--","total_space_estimator",":","BaseEstimator","Frechet","mean","estimator","in","total","space",".","estimate_",":","array-like",",","mean=","[","n_nodes",",","n_nodes","]","Mean",".","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 Frechet Mean.
  
  Parameters
  ----------
  X : array-like, shape=[n_samples, n_nodes, n_nodes] or set of GraphPoint.
      Dataset to estimate the FM.
  y : Ignored
      Ignored.
  
  Returns
  -------
  self : object
      Returns self.
docstr_tok: ["Fit","the","Frechet","Mean",".","Parameters","--","--","--","--","--","X",":","array-like",",","shape=","[","n_samples",",","n_nodes",",","n_nodes","]","or","set","of","GraphPoint",".","Dataset","to","estimate","the","FM",".","y",":","Ignored","Ignored",".","Returns","--","--","--","-","self",":","object","Returns","self","."]
code: def fit(self, X, y=None):
      """Fit the Frechet Mean.
  
      Parameters
      ----------
      X : array-like, shape=[n_samples, n_nodes, n_nodes] or set of GraphPoint.
          Dataset to estimate the FM.
      y : Ignored
          Ignored.
  
      Returns
      -------
      self : object
          Returns self.
      """
      previous_estimate = (
          random.choice(X)
          if self.init_point is None
          else self.init_point
      )
      aligned_X = X
      error = self.epsilon + 1
      iteration = 0
      while error > self.epsilon and iteration < self.max_iter:
          iteration += 1
  
          aligned_X = self.metric.align_point_to_point(
              previous_estimate, aligned_X
          )
          new_estimate = self.total_space_estimator.fit(
              aligned_X
          ).estimate_
          error = self.metric.total_space_metric.dist(
              previous_estimate, new_estimate
          )
  
          previous_estimate = new_estimate
  
      _warn_max_iterations(iteration, self.max_iter)
      if self.save_last_X:
          self.aligned_X_ = aligned_X
      self.estimate_ = new_estimate
      self.n_iter_ = iteration
  
      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 2 for calling the _AACFrechetMean obj's underlying member method code with example usage: obj.fit(X, y) and returns: self