class_docstr: Reconciles forecasts to satisfy additive constraints.
  
  Constraints can be encoded by the tree structure via ``levels``.
  In the tree formulation, a parent's value must be the sum of its children's values.
  
  Or, constraints can be encoded as a matrix via ``constraint_matrix``,
  specifying additive expressions that must equal 0. The constraints need not have a
  tree representation.
  
  Provides standard methods such as bottom up, ols, MinT. Also supports a custom method
  that minimizes user-specified types of error. The solution is derived by convex optimization.
  If desired, a constraint is added to require the transformation to be unbiased.
  
  If not using method="ols" or method="bottom_up", which don't depend on the data,
  forecast reconciliation should be trained once per horizon
  (# periods between forecasted date and train_end_date),
  because the optimal adjustment may differ.
  
  Attributes
  ----------
  forecasts : `pandas.DataFrame`, shape (n, m)
      Original forecasted values, used to train the method.
      Also known as "base" forecasts.
      Long format where each column is a time series.
      and each row is a time step.
      For proper variance estimates for the variance penalty,
      values should be at a fixed-horizon (e.g. always 7-step ahead).
  actuals : `pandas.DataFrame`, shape (n, m)
      Actual values to train the method, corresponding to ``forecasts``.
      Must have the same shape and column names as ``forecasts``.
  constraint_matrix : `numpy.array`, shape (c, m), or None
      Constraints. ``c x m`` array encoding ``c`` constraints of ``m`` variables.
      We require ``constraint_matrix @ transform_matrix = 0``.
      For example, to encode ``-x1 + x2 + x3 == 0 and -x2 + x4 + x5 == 0``::
  
          constraint_matrix = np.array([
              [-1, 1, 1, 0, 0],
              [0, -1, 0, 1, 1]])
  
      Entries are typically in [-1, 0, 1], but this is not required.
      Either ``constraint_matrix`` or ``levels`` must be provided.
  
  levels : `list` [`list` [`int`]] or None
      A simpler way to encode tree constraints. Overrides ``constraint_matrix`` if provided.
      Specifies the number of children of each parent (internal) node in the tree.
      The number of inner lists is the height of the tree. The ith inner list provides the number
      of children of each node at depth i. For example::
  
          # root node with 3 children
          levels = [[3]]
          # root node with 3 children, who have 2, 3, 3 children respectively
          levels = [[3], [2, 3, 3]]
  
      All leaf nodes must have the same depth. Thus, the first sublist must have one
      integer, the length of a sublist must equal the sum of the previous sublist,
      and all integers in ``levels`` must be positive.
  
      Either ``constraint_matrix`` or ``levels`` must be provided.
  
  order_dict : `dict` [`str`, `float`] or None
      How to order the columns before fitting.
      The key is the column name, the value is its position.
      When ``levels`` is used, map each column name to the
      order of its corresponding node in a BFS traversal of the tree.
      When ``constraint_matrix`` is used, this shuffles the order
      of the columns before the constraints are applied (thus, columns
      in ``constraint_matrix`` refer to the columns after reordering).
  
      If None, no reordering is done.
  
  method : `str`
      Which reconciliation method to use.
      Valid values are "bottom_up", "ols", "mint_sample", "custom":
  
          - "bottom_up"   : Sums leaf nodes. Unbiased transform that uses only the values of the leaf nodes
                            to propagate up the tree. Each node's value is the sum of its
                            corresponding leaf nodes' values (a leaf node corresponds to a node T if it is
                            a leaf node of the subtree with T as its root, i.e. a descendant of T or T itself).
                            See Dangerfield and Morris 1992 "Top-down or bottom-up: Aggregate versus disaggregate
                            extrapolations" for one discussion of this method.
                            Depends only on the structure of the hierarchy, not on the data itself.
          - "ols"         : OLS estimate proposed by https://robjhyndman.com/papers/Hierarchical6.pdf
                            (Hyndman et al. 2010, "Optimal combination forecasts for hierarchical time series")
                            Also see https://robjhyndman.com/papers/mint.pdf section 2.4.1.
                            (Wickramasuriya et al. 2019 "Optimal forecast reconciliation for
                            hierarchical and grouped time series through trace minimization".)
                            Unbiased transform that minimizes variance of adjusted residuals,
                            using "identity" estimate of original residual variance.
                            Optimal if original forecast errors are uncorrelated with equal variance (unlikely).
                            Depends only on the structure of the hierarchy, not on the data itself.
          - "mint_sample" : Unbiased transform that minimizes variance of adjusted residuals,
                            using "sample" estimate of original residual variance.
                            Assumes base forecasts are unbiased.
                            See Wickramasuriya et al. 2019 section 2.4.4.
                            Depends on the structure of the hierarchy and forecast error covariances.
          - "custom"      : Optimization parameters can be set by the user. See
                            `greykite.algo.reconcile.convex.reconcile_forecasts.ReconcileAdditiveForecasts.fit`
                            method for parameters and their default values.
                            Depends on the structure of the hierarchy, base forecasts, and actuals, if all terms
                            are included in the objective.
  
      If "custom", uses the parameters passed to
      `greykite.algo.reconcile.convex.reconcile_forecasts.ReconcileAdditiveForecasts.fit`
      to formulate the convex optimization problem.
  
      If "bottom_up", "ols", or "mint_sample", the other fit parameters are ignored.
  
  lower_bound : `float` or None
      Lower bound on each entry of ``transform_matrix``.
      If None, no lower bound is applied.
  upper_bound : `float` or None
      Upper bound on each entry of ``transform_matrix``.
      If None, no upper bound is applied.
  unbiased : `bool`
      Whether the resulting transformation must be unbiased.
  lam_adj : `float`
      Weight for the adjustment penalty.
      The adjustment penalty is the mean squared difference
      between adjusted forecasts and base forecasts.
  lam_bias : `float`
      Weight for the bias penalty.
      The bias penalty is the mean squared difference
      between adjusted actuals and actuals.
      For an unbiased transformation (``unbiased=True``),
      the bias penalty is 0 so this has no effect.
  lam_train : `float`
      Weight for the training MSE penalty.
      The train MSE penalty measures the mean squared difference
      between adjusted forecasts and actuals.
  lam_var : `float`
      Weight for the variance penalty.
      The variance penalty measures the variance of
      adjusted forecast errors for an unbiased transformation.
      It is reported as the average of the variances across timeseries.
      It is based on the variance of the base forecast error
      variance, ``covariance``. For biased transforms,
      this is an underestimate of the true variance.
  covariance : `numpy.array` of shape (m, m), or "sample" or "identity"
      Variance-covariance matrix of base forecast errors. Used to
      compute the variance penalty.
  
          - If a `numpy.array`, row/column i corresponds to the
            ith column after reordering by ``order_dict``. Should
            be reported on the original scale of the data.
          - If "sample", the sample covariance of residuals
            assuming base forecasts are unbiased.
            Unlike `numpy.cov`, does not mean center the residuals,
            and divides by ``n`` instead of ``n-1``.
          - If "identity", the identity matrix.
  
  weight_adj : `numpy.array` or `list` [`float`] of length m or "MedAPE" or "InverseMedAPE" or None
      Weight for the adjustment penalty that allows a different
      weight per-timeseries.
  
          - If a numpy array/list, values specify the weight for each forecast
            after reordering by ``order_dict``.
          - If "MedAPE", proportional to the MedAPE of the forecast.
          - If "InverseMedAPE", proportional to 1 / MedAPE of the forecast. This can be useful
            to penalize adjustment to base forecasts that are already accurate.
          - If None, the identity matrix (equal weights).
  
  weight_bias : `numpy.array` or `list` [`float`] of length m or "MedAPE" or "InverseMedAPE" or None
      Weight for the bias penalty that allows a different
      weight per-timeseries.
  
          - If a numpy array/list, values specify the weight for each forecast
            after reordering by ``order_dict``.
          - If "MedAPE", proportional to the MedAPE of the forecast. This can be useful
            to focus more on improving the base forecasts with high error.
          - If "InverseMedAPE", proportional to 1 / MedAPE of the forecast.
          - If None, the identity matrix (equal weights).
  
      For an unbiased transformation (``unbiased=True``),
      the bias penalty is 0 so this has no effect.
  
  weight_train : `numpy.array` or `list` [`float`] of length m or "MedAPE" or "InverseMedAPE" or None
      Weight for the train MSE penalty that allows a different
      weight per-timeseries.
  
          - If a numpy array/list, values specify the weight for each forecast
            after reordering by ``order_dict``.
          - If "MedAPE", proportional to the MedAPE of the forecast. This can be useful
            to focus more on improving the base forecasts with high error.
          - If "InverseMedAPE", proportional to 1 / MedAPE of the forecast.
          - If None, the identity matrix (equal weights).
  
  weight_var : `numpy.array` or `list` [`float`] of length m or "MedAPE" or "InverseMedAPE" or None
      Weight for the variance penalty that allows a different
      weight per-timeseries.
  
          - If a numpy array/list, values specify the weight for each forecast
            after reordering by ``order_dict``.
          - If "MedAPE", proportional to the MedAPE of the forecast. This can be useful
            to focus more on improving the base forecasts with high error.
          - If "InverseMedAPE", proportional to 1 / MedAPE of the forecast.
          - If None, the identity matrix (equal weights).
  
  names : `pandas.Index`
      Names of ``forecast`` columns after reordering by ``order_dict``.
  tree : `greykite.algo.reconcile.hierarchical_relationship.HierarchicalRelationship` or None
      If ``levels`` is provided, represents the tree structure encoded by the levels.
      Else None.
  transform_variable : `cvxpy.Variable`, shape (m, m) or None
      Optimization variable to learn the transform matrix.
      None if a rule-based method is used, e.g. ``method == bottom_up``
  transform_matrix : `numpy.array`, shape (m, m)
      Transformation matrix. Same as ``transform_variable.value``, unless
      the solver failed the find a solution, and a backup value is used.
      Adjusted forecasts are computed by applying the transform from the left
      to reordered and transposed ``forecasts``. See ``transform`` in this class.
  prob : `cvxpy.Problem`
      Convex optimization problem.
  is_optimization_solution : `bool`
      Whether ``transform_matrix`` is a solution found by convex optimization solution.
      If False, then ``transform_matrix`` may be set to a backup value (bottom up transform).
      Check ``prob.status`` for more details about solver status.
  objective_fn : `callable`
      Evaluates the objective function for a given transform matrix and dataset.
      Takes ``transform_matrix, forecast_matrix (optional), actual_matrix (optional)``.
      Return value has same format as ``objective_fn_val``.
      If forecast_matrix/actual_matrix are not provided, uses the fitting datasets.
  objective_fn_val : `dict` [`str`, `float`]
      Dictionary containing the objective value, and its components,
      as evaluated on the training set for the identified optimal solution
      from convex optimization.
      Keys are:
  
          ``"adj"``    : adjustment size
          ``"bias"``   : bias of estimator
          ``"train"``  : train set MSE
          ``"var"``    : variance of unbiased estimator
          ``"total"``  : sum of the above
  
  objective_weights : `dict` [`str`, `np.array` of shape (m, m)]
      Weights used in the objective function, derived from
      ``covariance``, ``weight_*``, ``forecasts``, ``actuals``.
      Keys are:
  
          - weight_adj
          - weight_bias
          - weight_train
          - weight_var
          - covariance
  
  adjusted_forecasts : `pandas.DataFrame`, shape (n, m)
      Adjusted ``forecasts`` that satisfy the constraints.
  constraint_violation : `dict` [`str`, `float`]
      The normalized constraint violations on training set.
      Keys are "actual", "forecast", and "adjusted".
      Root mean squared constraint violation is divided by root mean squared actual value.
  evaluation_df : `pandas.DataFrame`, shape (m, # metrics)
      DataFrame of evaluation results on training set. Rows are timeseries,
      columns are metrics. See ``evaluate`` in this class.
  figures : `dict` [`str`, `plotly.graph_objects.Figure`] or None
      Plotly figures to visualize evaluation results on training set.
      Keys are: "base_adj" (base vs adjusted forecast),
      "adj_size" (adjustment size %), "error" (% error).
      Each figure contains multiple subplots, one for each timeseries.
  forecasts_test : `pandas.DataFrame`, shape (q, m)
      Forecasted values to test the method.
      Long format where each column is a time series
      and each row is a time step.
      Must have the same column names as ``forecasts``.
      Can have a different number of rows (observations).
  actuals_test : `pandas.DataFrame`, shape (q, m)
      Actual values to test the method.
      Must have the same shape and column names as ``forecasts_test``.
  adjusted_forecasts_test : `pandas.DataFrame`, shape (q, m)
      Adjusted ``forecasts_test`` that satisfy the constraints.
  constraint_violation_test : `dict` [`str`, `float`]
      The normalized constraint violations on test set.
      Keys are "actual", "forecast", and "adjusted".
      Root mean squared constraint violation is divided by root mean squared actual value
      on test set.
  evaluation_df_test : `pandas.DataFrame`, shape (m, # metrics)
      DataFrame of evaluation results on test set. Rows are timeseries,
      columns are metrics. See ``evaluate()`` in this class.
  figures_test : `dict` [`str`, `plotly.graph_objects.Figure`] or None
      Plotly figures to visualize evaluation results on test set.
      Keys are: "base_adj" (base vs adjusted forecast),
      "adj_size" (adjustment size %), "error" (% error).
      Each figure contains multiple subplots, one for each timeseries.
  
  Methods
  -------
  fit : callable
      Fits the ``transform_matrix`` from training data.
  transform : callable
      Adjusts a forecast to satisfy additive constraints using the ``transform_matrix``.
  evaluate : callable
      Evaluates the adjustment quality by its impact to MAPE, MedAPE, and RMSE.
  fit_transform : callable
      Fits and transforms the training data.
  fit_transform_evaluate : callable
      Fits, transforms, and evaluates on training data.
  transform_evaluate : calllable
      Transforms and evaluates on a new test set.
class_docstr_tok: ["Reconciles","forecasts","to","satisfy","additive","constraints",".","Constraints","can","be","encoded","by","the","tree","structure","via","``","levels","``",".","In","the","tree","formulation",",","a","parent","'s","value","must","be","the","sum","of","its","children","'s","values",".","Or",",","constraints","can","be","encoded","as","a","matrix","via","``","constraint_matrix","``",",","specifying","additive","expressions","that","must","equal","0",".","The","constraints","need","not","have","a","tree","representation",".","Provides","standard","methods","such","as","bottom","up",",","ols",",","MinT",".","Also","supports","a","custom","method","that","minimizes","user-specified","types","of","error",".","The","solution","is","derived","by","convex","optimization",".","If","desired",",","a","constraint","is","added","to","require","the","transformation","to","be","unbiased",".","If","not","using","method=","''","ols","''","or","method=","''","bottom_up","''",",","which","do","n't","depend","on","the","data",",","forecast","reconciliation","should","be","trained","once","per","horizon","(","#","periods","between","forecasted","date","and","train_end_date",")",",","because","the","optimal","adjustment","may","differ",".","Attributes","--","--","--","--","--","forecasts",":","`","pandas.DataFrame","`",",","shape","(","n",",","m",")","Original","forecasted","values",",","used","to","train","the","method",".","Also","known","as","``","base","''","forecasts",".","Long","format","where","each","column","is","a","time","series",".","and","each","row","is","a","time","step",".","For","proper","variance","estimates","for","the","variance","penalty",",","values","should","be","at","a","fixed-horizon","(","e.g",".","always","7-step","ahead",")",".","actuals",":","`","pandas.DataFrame","`",",","shape","(","n",",","m",")","Actual","values","to","train","the","method",",","corresponding","to","``","forecasts","``",".","Must","have","the","same","shape","and","column","names","as","``","forecasts","``",".","constraint_matrix",":","`","numpy.array","`",",","shape","(","c",",","m",")",",","or","None","Constraints",".","``","c","x","m","``","array","encoding","``","c","``","constraints","of","``","m","``","variables",".","We","require","``","constraint_matrix","@","transform_matrix","=","0","``",".","For","example",",","to","encode","``","-x1","+","x2","+","x3","==","0","and","-x2","+","x4","+","x5","==","0","``",":",":","constraint_matrix","=","np.array","(","[","[","-1",",","1",",","1",",","0",",","0","]",",","[","0",",","-1",",","0",",","1",",","1","]","]",")","Entries","are","typically","in","[","-1",",","0",",","1","]",",","but","this","is","not","required",".","Either","``","constraint_matrix","``","or","``","levels","``","must","be","provided",".","levels",":","`","list","`","[","`","list","`","[","`","int","`","]","]","or","None","A","simpler","way","to","encode","tree","constraints",".","Overrides","``","constraint_matrix","``","if","provided",".","Specifies","the","number","of","children","of","each","parent","(","internal",")","node","in","the","tree",".","The","number","of","inner","lists","is","the","height","of","the","tree",".","The","ith","inner","list","provides","the","number","of","children","of","each","node","at","depth","i",".","For","example",":",":","#","root","node","with","3","children","levels","=","[","[","3","]","]","#","root","node","with","3","children",",","who","have","2",",","3",",","3","children","respectively","levels","=","[","[","3","]",",","[","2",",","3",",","3","]","]","All","leaf","nodes","must","have","the","same","depth",".","Thus",",","the","first","sublist","must","have","one","integer",",","the","length","of","a","sublist","must","equal","the","sum","of","the","previous","sublist",",","and","all","integers","in","``","levels","``","must","be","positive",".","Either","``","constraint_matrix","``","or","``","levels","``","must","be","provided",".","order_dict",":","`","dict","`","[","`","str","`",",","`","float","`","]","or","None","How","to","order","the","columns","before","fitting",".","The","key","is","the","column","name",",","the","value","is","its","position",".","When","``","levels","``","is","used",",","map","each","column","name","to","the","order","of","its","corresponding","node","in","a","BFS","traversal","of","the","tree",".","When","``","constraint_matrix","``","is","used",",","this","shuffles","the","order","of","the","columns","before","the","constraints","are","applied","(","thus",",","columns","in","``","constraint_matrix","``","refer","to","the","columns","after","reordering",")",".","If","None",",","no","reordering","is","done",".","method",":","`","str","`","Which","reconciliation","method","to","use",".","Valid","values","are","``","bottom_up","''",",","``","ols","''",",","``","mint_sample","''",",","``","custom","''",":","-","``","bottom_up","''",":","Sums","leaf","nodes",".","Unbiased","transform","that","uses","only","the","values","of","the","leaf","nodes","to","propagate","up","the","tree",".","Each","node","'s","value","is","the","sum","of","its","corresponding","leaf","nodes","'","values","(","a","leaf","node","corresponds","to","a","node","T","if","it","is","a","leaf","node","of","the","subtree","with","T","as","its","root",",","i.e",".","a","descendant","of","T","or","T","itself",")",".","See","Dangerfield","and","Morris","1992","``","Top-down","or","bottom-up",":","Aggregate","versus","disaggregate","extrapolations","''","for","one","discussion","of","this","method",".","Depends","only","on","the","structure","of","the","hierarchy",",","not","on","the","data","itself",".","-","``","ols","''",":","OLS","estimate","proposed","by","https",":","\/\/robjhyndman.com\/papers\/Hierarchical6.pdf","(","Hyndman","et","al",".","2010",",","``","Optimal","combination","forecasts","for","hierarchical","time","series","''",")","Also","see","https",":","\/\/robjhyndman.com\/papers\/mint.pdf","section","2.4.1",".","(","Wickramasuriya","et","al",".","2019","``","Optimal","forecast","reconciliation","for","hierarchical","and","grouped","time","series","through","trace","minimization","''",".",")","Unbiased","transform","that","minimizes","variance","of","adjusted","residuals",",","using","``","identity","''","estimate","of","original","residual","variance",".","Optimal","if","original","forecast","errors","are","uncorrelated","with","equal","variance","(","unlikely",")",".","Depends","only","on","the","structure","of","the","hierarchy",",","not","on","the","data","itself",".","-","``","mint_sample","''",":","Unbiased","transform","that","minimizes","variance","of","adjusted","residuals",",","using","``","sample","''","estimate","of","original","residual","variance",".","Assumes","base","forecasts","are","unbiased",".","See","Wickramasuriya","et","al",".","2019","section","2.4.4",".","Depends","on","the","structure","of","the","hierarchy","and","forecast","error","covariances",".","-","``","custom","''",":","Optimization","parameters","can","be","set","by","the","user",".","See","`","greykite.algo.reconcile.convex.reconcile_forecasts.ReconcileAdditiveForecasts.fit","`","method","for","parameters","and","their","default","values",".","Depends","on","the","structure","of","the","hierarchy",",","base","forecasts",",","and","actuals",",","if","all","terms","are","included","in","the","objective",".","If","``","custom","''",",","uses","the","parameters","passed","to","`","greykite.algo.reconcile.convex.reconcile_forecasts.ReconcileAdditiveForecasts.fit","`","to","formulate","the","convex","optimization","problem",".","If","``","bottom_up","''",",","``","ols","''",",","or","``","mint_sample","''",",","the","other","fit","parameters","are","ignored",".","lower_bound",":","`","float","`","or","None","Lower","bound","on","each","entry","of","``","transform_matrix","``",".","If","None",",","no","lower","bound","is","applied",".","upper_bound",":","`","float","`","or","None","Upper","bound","on","each","entry","of","``","transform_matrix","``",".","If","None",",","no","upper","bound","is","applied",".","unbiased",":","`","bool","`","Whether","the","resulting","transformation","must","be","unbiased",".","lam_adj",":","`","float","`","Weight","for","the","adjustment","penalty",".","The","adjustment","penalty","is","the","mean","squared","difference","between","adjusted","forecasts","and","base","forecasts",".","lam_bias",":","`","float","`","Weight","for","the","bias","penalty",".","The","bias","penalty","is","the","mean","squared","difference","between","adjusted","actuals","and","actuals",".","For","an","unbiased","transformation","(","``","unbiased=True","``",")",",","the","bias","penalty","is","0","so","this","has","no","effect",".","lam_train",":","`","float","`","Weight","for","the","training","MSE","penalty",".","The","train","MSE","penalty","measures","the","mean","squared","difference","between","adjusted","forecasts","and","actuals",".","lam_var",":","`","float","`","Weight","for","the","variance","penalty",".","The","variance","penalty","measures","the","variance","of","adjusted","forecast","errors","for","an","unbiased","transformation",".","It","is","reported","as","the","average","of","the","variances","across","timeseries",".","It","is","based","on","the","variance","of","the","base","forecast","error","variance",",","``","covariance","``",".","For","biased","transforms",",","this","is","an","underestimate","of","the","true","variance",".","covariance",":","`","numpy.array","`","of","shape","(","m",",","m",")",",","or","``","sample","''","or","``","identity","''","Variance-covariance","matrix","of","base","forecast","errors",".","Used","to","compute","the","variance","penalty",".","-","If","a","`","numpy.array","`",",","row\/column","i","corresponds","to","the","ith","column","after","reordering","by","``","order_dict","``",".","Should","be","reported","on","the","original","scale","of","the","data",".","-","If","``","sample","''",",","the","sample","covariance","of","residuals","assuming","base","forecasts","are","unbiased",".","Unlike","`","numpy.cov","`",",","does","not","mean","center","the","residuals",",","and","divides","by","``","n","``","instead","of","``","n-1","``",".","-","If","``","identity","''",",","the","identity","matrix",".","weight_adj",":","`","numpy.array","`","or","`","list","`","[","`","float","`","]","of","length","m","or","``","MedAPE","''","or","``","InverseMedAPE","''","or","None","Weight","for","the","adjustment","penalty","that","allows","a","different","weight","per-timeseries",".","-","If","a","numpy","array\/list",",","values","specify","the","weight","for","each","forecast","after","reordering","by","``","order_dict","``",".","-","If","``","MedAPE","''",",","proportional","to","the","MedAPE","of","the","forecast",".","-","If","``","InverseMedAPE","''",",","proportional","to","1","\/","MedAPE","of","the","forecast",".","This","can","be","useful","to","penalize","adjustment","to","base","forecasts","that","are","already","accurate",".","-","If","None",",","the","identity","matrix","(","equal","weights",")",".","weight_bias",":","`","numpy.array","`","or","`","list","`","[","`","float","`","]","of","length","m","or","``","MedAPE","''","or","``","InverseMedAPE","''","or","None","Weight","for","the","bias","penalty","that","allows","a","different","weight","per-timeseries",".","-","If","a","numpy","array\/list",",","values","specify","the","weight","for","each","forecast","after","reordering","by","``","order_dict","``",".","-","If","``","MedAPE","''",",","proportional","to","the","MedAPE","of","the","forecast",".","This","can","be","useful","to","focus","more","on","improving","the","base","forecasts","with","high","error",".","-","If","``","InverseMedAPE","''",",","proportional","to","1","\/","MedAPE","of","the","forecast",".","-","If","None",",","the","identity","matrix","(","equal","weights",")",".","For","an","unbiased","transformation","(","``","unbiased=True","``",")",",","the","bias","penalty","is","0","so","this","has","no","effect",".","weight_train",":","`","numpy.array","`","or","`","list","`","[","`","float","`","]","of","length","m","or","``","MedAPE","''","or","``","InverseMedAPE","''","or","None","Weight","for","the","train","MSE","penalty","that","allows","a","different","weight","per-timeseries",".","-","If","a","numpy","array\/list",",","values","specify","the","weight","for","each","forecast","after","reordering","by","``","order_dict","``",".","-","If","``","MedAPE","''",",","proportional","to","the","MedAPE","of","the","forecast",".","This","can","be","useful","to","focus","more","on","improving","the","base","forecasts","with","high","error",".","-","If","``","InverseMedAPE","''",",","proportional","to","1","\/","MedAPE","of","the","forecast",".","-","If","None",",","the","identity","matrix","(","equal","weights",")",".","weight_var",":","`","numpy.array","`","or","`","list","`","[","`","float","`","]","of","length","m","or","``","MedAPE","''","or","``","InverseMedAPE","''","or","None","Weight","for","the","variance","penalty","that","allows","a","different","weight","per-timeseries",".","-","If","a","numpy","array\/list",",","values","specify","the","weight","for","each","forecast","after","reordering","by","``","order_dict","``",".","-","If","``","MedAPE","''",",","proportional","to","the","MedAPE","of","the","forecast",".","This","can","be","useful","to","focus","more","on","improving","the","base","forecasts","with","high","error",".","-","If","``","InverseMedAPE","''",",","proportional","to","1","\/","MedAPE","of","the","forecast",".","-","If","None",",","the","identity","matrix","(","equal","weights",")",".","names",":","`","pandas.Index","`","Names","of","``","forecast","``","columns","after","reordering","by","``","order_dict","``",".","tree",":","`","greykite.algo.reconcile.hierarchical_relationship.HierarchicalRelationship","`","or","None","If","``","levels","``","is","provided",",","represents","the","tree","structure","encoded","by","the","levels",".","Else","None",".","transform_variable",":","`","cvxpy.Variable","`",",","shape","(","m",",","m",")","or","None","Optimization","variable","to","learn","the","transform","matrix",".","None","if","a","rule-based","method","is","used",",","e.g",".","``","method","==","bottom_up","``","transform_matrix",":","`","numpy.array","`",",","shape","(","m",",","m",")","Transformation","matrix",".","Same","as","``","transform_variable.value","``",",","unless","the","solver","failed","the","find","a","solution",",","and","a","backup","value","is","used",".","Adjusted","forecasts","are","computed","by","applying","the","transform","from","the","left","to","reordered","and","transposed","``","forecasts","``",".","See","``","transform","``","in","this","class",".","prob",":","`","cvxpy.Problem","`","Convex","optimization","problem",".","is_optimization_solution",":","`","bool","`","Whether","``","transform_matrix","``","is","a","solution","found","by","convex","optimization","solution",".","If","False",",","then","``","transform_matrix","``","may","be","set","to","a","backup","value","(","bottom","up","transform",")",".","Check","``","prob.status","``","for","more","details","about","solver","status",".","objective_fn",":","`","callable","`","Evaluates","the","objective","function","for","a","given","transform","matrix","and","dataset",".","Takes","``","transform_matrix",",","forecast_matrix","(","optional",")",",","actual_matrix","(","optional",")","``",".","Return","value","has","same","format","as","``","objective_fn_val","``",".","If","forecast_matrix\/actual_matrix","are","not","provided",",","uses","the","fitting","datasets",".","objective_fn_val",":","`","dict","`","[","`","str","`",",","`","float","`","]","Dictionary","containing","the","objective","value",",","and","its","components",",","as","evaluated","on","the","training","set","for","the","identified","optimal","solution","from","convex","optimization",".","Keys","are",":","``","``","adj","''","``",":","adjustment","size","``","``","bias","''","``",":","bias","of","estimator","``","``","train","''","``",":","train","set","MSE","``","``","var","''","``",":","variance","of","unbiased","estimator","``","``","total","''","``",":","sum","of","the","above","objective_weights",":","`","dict","`","[","`","str","`",",","`","np.array","`","of","shape","(","m",",","m",")","]","Weights","used","in","the","objective","function",",","derived","from","``","covariance","``",",","``","weight_","*","``",",","``","forecasts","``",",","``","actuals","``",".","Keys","are",":","-","weight_adj","-","weight_bias","-","weight_train","-","weight_var","-","covariance","adjusted_forecasts",":","`","pandas.DataFrame","`",",","shape","(","n",",","m",")","Adjusted","``","forecasts","``","that","satisfy","the","constraints",".","constraint_violation",":","`","dict","`","[","`","str","`",",","`","float","`","]","The","normalized","constraint","violations","on","training","set",".","Keys","are","``","actual","''",",","``","forecast","''",",","and","``","adjusted","''",".","Root","mean","squared","constraint","violation","is","divided","by","root","mean","squared","actual","value",".","evaluation_df",":","`","pandas.DataFrame","`",",","shape","(","m",",","#","metrics",")","DataFrame","of","evaluation","results","on","training","set",".","Rows","are","timeseries",",","columns","are","metrics",".","See","``","evaluate","``","in","this","class",".","figures",":","`","dict","`","[","`","str","`",",","`","plotly.graph_objects.Figure","`","]","or","None","Plotly","figures","to","visualize","evaluation","results","on","training","set",".","Keys","are",":","``","base_adj","''","(","base","vs","adjusted","forecast",")",",","``","adj_size","''","(","adjustment","size","%",")",",","``","error","''","(","%","error",")",".","Each","figure","contains","multiple","subplots",",","one","for","each","timeseries",".","forecasts_test",":","`","pandas.DataFrame","`",",","shape","(","q",",","m",")","Forecasted","values","to","test","the","method",".","Long","format","where","each","column","is","a","time","series","and","each","row","is","a","time","step",".","Must","have","the","same","column","names","as","``","forecasts","``",".","Can","have","a","different","number","of","rows","(","observations",")",".","actuals_test",":","`","pandas.DataFrame","`",",","shape","(","q",",","m",")","Actual","values","to","test","the","method",".","Must","have","the","same","shape","and","column","names","as","``","forecasts_test","``",".","adjusted_forecasts_test",":","`","pandas.DataFrame","`",",","shape","(","q",",","m",")","Adjusted","``","forecasts_test","``","that","satisfy","the","constraints",".","constraint_violation_test",":","`","dict","`","[","`","str","`",",","`","float","`","]","The","normalized","constraint","violations","on","test","set",".","Keys","are","``","actual","''",",","``","forecast","''",",","and","``","adjusted","''",".","Root","mean","squared","constraint","violation","is","divided","by","root","mean","squared","actual","value","on","test","set",".","evaluation_df_test",":","`","pandas.DataFrame","`",",","shape","(","m",",","#","metrics",")","DataFrame","of","evaluation","results","on","test","set",".","Rows","are","timeseries",",","columns","are","metrics",".","See","``","evaluate","(",")","``","in","this","class",".","figures_test",":","`","dict","`","[","`","str","`",",","`","plotly.graph_objects.Figure","`","]","or","None","Plotly","figures","to","visualize","evaluation","results","on","test","set",".","Keys","are",":","``","base_adj","''","(","base","vs","adjusted","forecast",")",",","``","adj_size","''","(","adjustment","size","%",")",",","``","error","''","(","%","error",")",".","Each","figure","contains","multiple","subplots",",","one","for","each","timeseries",".","Methods","--","--","--","-","fit",":","callable","Fits","the","``","transform_matrix","``","from","training","data",".","transform",":","callable","Adjusts","a","forecast","to","satisfy","additive","constraints","using","the","``","transform_matrix","``",".","evaluate",":","callable","Evaluates","the","adjustment","quality","by","its","impact","to","MAPE",",","MedAPE",",","and","RMSE",".","fit_transform",":","callable","Fits","and","transforms","the","training","data",".","fit_transform_evaluate",":","callable","Fits",",","transforms",",","and","evaluates","on","training","data",".","transform_evaluate",":","calllable","Transforms","and","evaluates","on","a","new","test","set","."]
docstr: Transforms and evaluates on test data.
  
  Must call ``fit`` before calling this method.
  
  forecasts_test : `pandas.DataFrame`
      Forecasts to make consistent. Should be different from the training data.
  actuals_test : `pandas.DataFrame`
      Actuals to check quality of the adjustment.
  evaluate_kwargs : `dict`, optional, default None
      Additional parameters to pass to ``evaluate``.
  
  Returns
  -------
  evaluation_df_test : `pandas.DataFrame`
      Evaluation results on provided ``forecasts_test``.
docstr_tok: ["Transforms","and","evaluates","on","test","data",".","Must","call","``","fit","``","before","calling","this","method",".","forecasts_test",":","`","pandas.DataFrame","`","Forecasts","to","make","consistent",".","Should","be","different","from","the","training","data",".","actuals_test",":","`","pandas.DataFrame","`","Actuals","to","check","quality","of","the","adjustment",".","evaluate_kwargs",":","`","dict","`",",","optional",",","default","None","Additional","parameters","to","pass","to","``","evaluate","``",".","Returns","--","--","--","-","evaluation_df_test",":","`","pandas.DataFrame","`","Evaluation","results","on","provided","``","forecasts_test","``","."]
code: def transform_evaluate(
      self, forecasts_test, actuals_test, **evaluate_kwargs
  ):
      """Transforms and evaluates on test data.
  
      Must call ``fit`` before calling this method.
  
      forecasts_test : `pandas.DataFrame`
          Forecasts to make consistent. Should be different from the training data.
      actuals_test : `pandas.DataFrame`
          Actuals to check quality of the adjustment.
      evaluate_kwargs : `dict`, optional, default None
          Additional parameters to pass to ``evaluate``.
  
      Returns
      -------
      evaluation_df_test : `pandas.DataFrame`
          Evaluation results on provided ``forecasts_test``.
      """
      self.transform(forecasts_test)
      self.evaluate(
          is_train=False, actuals_test=actuals_test, **evaluate_kwargs
      )
      return self.evaluation_df_test
  
imports: import functools
  import logging
  import math
  import sys
  import warnings
  from dataclasses import dataclass
  from typing import Optional
  import cvxpy
  import numpy
  import pandas
  import plotly
  import plotly.express
  from plotly import graph_objects
  from plotly.subplots import make_subplots
  from scipy.linalg import sqrtm
  from sklearn.exceptions import NotFittedError
  from greykite.algo.reconcile.hierarchical_relationship import HierarchicalRelationship
  from greykite.common.python_utils import reorder_columns
label_desc: Use image node_id 9 for calling the ReconcileAdditiveForecasts obj's underlying member method code with example usage: obj.transform_evaluate(forecasts_test, actuals_test) and returns: self