docstr: Average across the components, keep n_samples, rename components
docstr_tok: ["Average","across","the","components",",","keep","n_samples",",","rename","components"]
code: def _target_average(
      self, prediction: TimeSeries, series: TimeSeries
  ) -> TimeSeries:
      """Average across the components, keep n_samples, rename components"""
      n_forecasting_models = len(self.forecasting_models)
      n_components = series.n_components
      prediction_values = prediction.all_values(copy=False)
      target_values = np.zeros(
          (prediction.n_timesteps, n_components, prediction.n_samples)
      )
      for idx_target in range(n_components):
          target_values[:, idx_target] = prediction_values[
              :,
              range(
                  idx_target,
                  n_forecasting_models * n_components,
                  n_components,
              ),
          ].mean(axis=1)
  
      return TimeSeries.from_times_and_values(
          times=prediction.time_index,
          values=target_values,
          freq=series.freq,
          columns=series.components,
          static_covariates=series.static_covariates,
          hierarchy=series.hierarchy,
      )
  
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 4 for calling the NaiveEnsembleModel obj's underlying member method code with example usage: obj._target_average(prediction, series) and returns: TimeSeries