class_docstr: Aggregates hierarchical data, fit forecasters and make predictions.
  
  Can apply different univariate forecaster either on different
  level of aggregation or on different hierarchical nodes.
  
  `HierarchyEnsembleForecaster` is passed forecaster/level or
  forecaster/node pairs. Level can only be int >= 0 with 0
  signifying the topmost level of aggregation.
  Node can only be a tuple of strings or list of tuples.
  
  Behaviour in `fit`, `predict`:
  For level pairs f_i, l_i passed, applies forecaster f_i to level l_i.
  For node pairs f_i, n_i passed, applies forecaster f_i on each node of n_i.
  if "default" argument passed, applies "default" forecaster on the
  remaining levels/nodes which are not mentioned in argument 'forecasters'.
  `predict` results are concatenated to one container with same columns as in `fit`.
  
  
  Parameters
  ----------
  forecasters : sktime forecaster, or list of tuples
              (str, estimator, int or list of tuple/s)
      if forecaster, clones of forecaster are applied to all aggregated levels.
      if list of tuples, with name = str, estimator is forecaster, level/node
      as int/tuples respectively.
      all levels/nodes must be present in 'forecasters' attribute if 'default'
      attribute is None
  
  by : {'node', 'level', default='level'}
      if 'level', applies a univariate forecaster on all the hierarchical
      nodes within a level of aggregation
      if 'node', applies separate univariate forecaster for each
      hierarchical node.
  
  default : sktime forecaster {default = None}
      if passed, applies 'default' forecaster on the nodes/levels
      not mentioned in the 'forecaster' argument.
  
  Examples
  --------
  >>> from sktime.forecasting.compose import HierarchyEnsembleForecaster
  >>> from sktime.forecasting.naive import NaiveForecaster
  >>> from sktime.forecasting.trend import PolynomialTrendForecaster, TrendForecaster
  >>> from sktime.utils._testing.hierarchical import _bottom_hier_datagen
  >>> y = _bottom_hier_datagen(
  ...         no_bottom_nodes=7,
  ...         no_levels=2,
  ...         random_seed=123
  ... )
  
  >>> # Example of by = 'level'
  >>> forecasters = [
  ...     ('naive', NaiveForecaster(), 0),
  ...     ('trend', TrendForecaster(), 1)
  ... ]
  >>> forecaster = HierarchyEnsembleForecaster(
  ...                 forecasters=forecasters,
  ...                 by='level', default = PolynomialTrendForecaster(degree=2)
  ... )
  >>> forecaster.fit(y, fh=[1, 2, 3])
  HierarchyEnsembleForecaster(...)
  >>> y_pred = forecaster.predict()
  
  >>> # Example of by = 'node'
  >>> forecasters = [
  ...     ('trend', TrendForecaster(), [("__total", "__total")]),
  ...     ('poly', PolynomialTrendForecaster(degree=2), [('l2_node01', 'l1_node01')]),
  ... ]
  >>> forecaster = HierarchyEnsembleForecaster(
  ...                 forecasters=forecasters,
  ...                 by='node', default=NaiveForecaster()
  ... )
  >>> forecaster.fit(y, fh=[1, 2, 3])
  HierarchyEnsembleForecaster(...)
  >>> y_pred = forecaster.predict()
class_docstr_tok: ["Aggregates","hierarchical","data",",","fit","forecasters","and","make","predictions",".","Can","apply","different","univariate","forecaster","either","on","different","level","of","aggregation","or","on","different","hierarchical","nodes",".","`","HierarchyEnsembleForecaster","`","is","passed","forecaster\/level","or","forecaster\/node","pairs",".","Level","can","only","be","int",">","=","0","with","0","signifying","the","topmost","level","of","aggregation",".","Node","can","only","be","a","tuple","of","strings","or","list","of","tuples",".","Behaviour","in","`","fit","`",",","`","predict","`",":","For","level","pairs","f_i",",","l_i","passed",",","applies","forecaster","f_i","to","level","l_i",".","For","node","pairs","f_i",",","n_i","passed",",","applies","forecaster","f_i","on","each","node","of","n_i",".","if","``","default","''","argument","passed",",","applies","``","default","''","forecaster","on","the","remaining","levels\/nodes","which","are","not","mentioned","in","argument","'forecasters","'",".","`","predict","`","results","are","concatenated","to","one","container","with","same","columns","as","in","`","fit","`",".","Parameters","--","--","--","--","--","forecasters",":","sktime","forecaster",",","or","list","of","tuples","(","str",",","estimator",",","int","or","list","of","tuple\/s",")","if","forecaster",",","clones","of","forecaster","are","applied","to","all","aggregated","levels",".","if","list","of","tuples",",","with","name","=","str",",","estimator","is","forecaster",",","level\/node","as","int\/tuples","respectively",".","all","levels\/nodes","must","be","present","in","'forecasters","'","attribute","if","'default'","attribute","is","None","by",":","{","'node","'",",","'level","'",",","default='level","'","}","if","'level","'",",","applies","a","univariate","forecaster","on","all","the","hierarchical","nodes","within","a","level","of","aggregation","if","'node","'",",","applies","separate","univariate","forecaster","for","each","hierarchical","node",".","default",":","sktime","forecaster","{","default","=","None","}","if","passed",",","applies","'default","'","forecaster","on","the","nodes\/levels","not","mentioned","in","the","'forecaster","'","argument",".","Examples","--","--","--","--",">",">",">","from","sktime.forecasting.compose","import","HierarchyEnsembleForecaster",">",">",">","from","sktime.forecasting.naive","import","NaiveForecaster",">",">",">","from","sktime.forecasting.trend","import","PolynomialTrendForecaster",",","TrendForecaster",">",">",">","from","sktime.utils._testing.hierarchical","import","_bottom_hier_datagen",">",">",">","y","=","_bottom_hier_datagen","(","...","no_bottom_nodes=7",",","...","no_levels=2",",","...","random_seed=123","...",")",">",">",">","#","Example","of","by","=","'level'",">",">",">","forecasters","=","[","...","(","'naive","'",",","NaiveForecaster","(",")",",","0",")",",","...","(","'trend","'",",","TrendForecaster","(",")",",","1",")","...","]",">",">",">","forecaster","=","HierarchyEnsembleForecaster","(","...","forecasters=forecasters",",","...","by='level","'",",","default","=","PolynomialTrendForecaster","(","degree=2",")","...",")",">",">",">","forecaster.fit","(","y",",","fh=","[","1",",","2",",","3","]",")","HierarchyEnsembleForecaster","(","...",")",">",">",">","y_pred","=","forecaster.predict","(",")",">",">",">","#","Example","of","by","=","'node'",">",">",">","forecasters","=","[","...","(","'trend","'",",","TrendForecaster","(",")",",","[","(","``","__total","''",",","``","__total","''",")","]",")",",","...","(","'poly","'",",","PolynomialTrendForecaster","(","degree=2",")",",","[","(","'l2_node01","'",",","'l1_node01","'",")","]",")",",","...","]",">",">",">","forecaster","=","HierarchyEnsembleForecaster","(","...","forecasters=forecasters",",","...","by='node","'",",","default=NaiveForecaster","(",")","...",")",">",">",">","forecaster.fit","(","y",",","fh=","[","1",",","2",",","3","]",")","HierarchyEnsembleForecaster","(","...",")",">",">",">","y_pred","=","forecaster.predict","(",")"]
code: def __init__(self, forecasters, by="level", default=None):
      self.forecasters = forecasters
      self.by = by
      self.default = default
      super().__init__(forecasters=forecasters)
  
      if isinstance(forecasters, BaseForecaster):
          tags_to_clone = [
              "requires-fh-in-fit",
              "ignores-exogeneous-X",
              "handles-missing-data",
          ]
          self.clone_tags(forecasters, tags_to_clone)
      else:
          l_forecasters = [(x[0], x[1]) for x in forecasters]
          self._anytagis_then_set(
              "requires-fh-in-fit", True, False, l_forecasters
          )
          self._anytagis_then_set(
              "ignores-exogeneous-X", False, True, l_forecasters
          )
          self._anytagis_then_set(
              "handles-missing-data", False, True, l_forecasters
          )
  
file_path: sktime/sktime/forecasting/compose/_hierarchy_ensemble.py
imports: import pandas
  from sktime.base._meta import flatten
  from sktime.forecasting.base._base import BaseForecaster
  from sktime.forecasting.base._meta import _HeterogenousEnsembleForecaster
  from sktime.transformations.hierarchical.aggregate import _check_index_no_total
  from sktime.utils.warnings import warn
label_desc: Use image node_id 1 to create a new HierarchyEnsembleForecaster object from inherited base classes: _HeterogenousEnsembleForecaster with example: obj = HierarchyEnsembleForecaster(forecasters, by, default)