docstr: Average across the components after grouping by likelihood parameter, rename components
docstr_tok: ["Average","across","the","components","after","grouping","by","likelihood","parameter",",","rename","components"]
code: def _params_average(
      self, prediction: TimeSeries, series: TimeSeries
  ) -> TimeSeries:
      """Average across the components after grouping by likelihood parameter, rename components"""
      # str or torch Likelihood
      likelihood = getattr(self.forecasting_models[0], "likelihood")
      if isinstance(likelihood, str):
          likelihood_n_params = self.forecasting_models[
              0
          ].num_parameters
      else:  # Likelihood
          likelihood_n_params = likelihood.num_parameters
      n_forecasting_models = len(self.forecasting_models)
      n_components = series.n_components
      # aggregate across predictions [model1_param0, model1_param1, ..., modeln_param0, modeln_param1]
      prediction_values = prediction.values(copy=False)
      params_values = np.zeros(
          (prediction.n_timesteps, likelihood_n_params * n_components)
      )
      for idx_param in range(likelihood_n_params * n_components):
          params_values[:, idx_param] = prediction_values[
              :,
              range(
                  idx_param,
                  likelihood_n_params
                  * n_forecasting_models
                  * n_components,
                  likelihood_n_params * n_components,
              ),
          ].mean(axis=1)
  
      return TimeSeries.from_times_and_values(
          times=prediction.time_index,
          values=params_values,
          freq=series.freq,
          columns=prediction.components[
              : likelihood_n_params * n_components
          ],
          static_covariates=None,
          hierarchy=None,
      )
  
imports: from typing import List, Optional, Sequence, Union
  import numpy
  from darts.logging import get_logger, raise_if, raise_if_not
  from darts.models.forecasting.ensemble_model import EnsembleModel
  from darts.models.forecasting.forecasting_model import ForecastingModel, LocalForecastingModel
  from darts.timeseries import TimeSeries
label_desc: Use image node_id 5 for calling the NaiveEnsembleModel obj's underlying member method code with example usage: obj._params_average(prediction, series) and returns: TimeSeries