class_docstr: Class AAC for Generalized Geodesic Regression (GGR) on Graph Space.
  
  The Align All and Compute (AAC) algorithm for GGR estimation is
  introduced in [Calissano2022] and it estimates the GGR for
  :math:`\{(s_i, X_i)\in \mathbb{R}^p\times X/T\}` a set of labeled or unlabeled
  graphs as output and a set of scalar or vector as input:
  :math:`f: \mathbb{R}^p \rightarrow X/T`. The idea is to iteratively estimate a OLS
  regression model between a set of regressors and a set of flattened adjacency
  matrices and align the graphs to the current GGR estimator using the optimal
  alignment for regression. The optimal alignment for regression consists in aligning
  the graph with the corresponding predicted graph along the regression model to
  decrease the prediction error. The algorithm stops as soon as the loss 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 a 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 loss
      function in two consecutive estimation steps.
  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_y: 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
      Method for the estimation of the OLS Regression for a set of flattened adjacency
      matrices in the total space.
      Check geomstats.learning._sklearn_wrapper for details.
      Default: ``sklearn.linear_model.LinearRegression``.
  aligned_y_: 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 ``self.save_last_y is True``.
  
  References
  ----------
  .. [Calissano2022]  Calissano, A., Feragen, A., Vantini, S.
      “Graph-valued regression: prediction of unlabelled networks in a non-Euclidean
      Graph Space.”Journal of Multivariate Analysis 190 - 104950, (2022).
      https://doi.org/10.1016/j.jmva.2022.104950.
class_docstr_tok: ["Class","AAC","for","Generalized","Geodesic","Regression","(","GGR",")","on","Graph","Space",".","The","Align","All","and","Compute","(","AAC",")","algorithm","for","GGR","estimation","is","introduced","in","[","Calissano2022","]","and","it","estimates","the","GGR","for",":","math",":","`","\\","{","(","s_i",",","X_i",")","\\in","\\mathbb","{","R","}","^p\\times","X\/T\\","}","`","a","set","of","labeled","or","unlabeled","graphs","as","output","and","a","set","of","scalar","or","vector","as","input",":",":","math",":","`","f",":","\\mathbb","{","R","}","^p","\\rightarrow","X\/T","`",".","The","idea","is","to","iteratively","estimate","a","OLS","regression","model","between","a","set","of","regressors","and","a","set","of","flattened","adjacency","matrices","and","align","the","graphs","to","the","current","GGR","estimator","using","the","optimal","alignment","for","regression",".","The","optimal","alignment","for","regression","consists","in","aligning","the","graph","with","the","corresponding","predicted","graph","along","the","regression","model","to","decrease","the","prediction","error",".","The","algorithm","stops","as","soon","as","the","loss","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","a","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","loss","function","in","two","consecutive","estimation","steps",".","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_y",":","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","Method","for","the","estimation","of","the","OLS","Regression","for","a","set","of","flattened","adjacency","matrices","in","the","total","space",".","Check","geomstats.learning._sklearn_wrapper","for","details",".","Default",":","``","sklearn.linear_model.LinearRegression","``",".","aligned_y_",":","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","``","self.save_last_y","is","True","``",".","References","--","--","--","--","--","..","[","Calissano2022","]","Calissano",",","A.",",","Feragen",",","A.",",","Vantini",",","S.","\u201c","Graph-valued","regression",":","prediction","of","unlabelled","networks","in","a","non-Euclidean","Graph","Space.","\u201d","Journal","of","Multivariate","Analysis","190","-","104950",",","(","2022",")",".","https",":","\/\/doi.org\/10.1016\/j.jmva.2022.104950","."]
docstr: Compute the prediction error.
docstr_tok: ["Compute","the","prediction","error","."]
code: def _compute_pred_error(self, y_pred, y):
      """Compute the prediction error."""
      # order matters for reuse of perm_
      return gs.sum(self.metric.dist(y_pred, y))
  
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 _AACRegression obj's underlying member method code with example usage: obj._compute_pred_error(y_pred, y) and returns: gs