code: def evaluate(
      dataset: base.typing.Dataset,
      model: time_series.base.Forecaster,
      metric: metrics.base.RegressionMetric,
      horizon: int,
      agg_func: typing.Callable[[list[float]], float] | None = None,
      grace_period: int | None = None,
  ) -> time_series.HorizonMetric:
      """Evaluates the performance of a forecaster on a time series dataset.
  
      To understand why this method is useful, it's important to understand the difference between
      nowcasting and forecasting. Nowcasting is about predicting a value at the next time step. This
      can be seen as a special case of regression, where the value to predict is the value at the
      next time step. In this case, the `evaluate.progressive_val_score` function may be used to
      evaluate a model via progressive validation.
  
      Forecasting models can also be evaluated via progressive validation. This is the purpose of
      this function. At each time step `t`, the forecaster is asked to predict the values at `t + 1`,
      `t + 2`, ..., `t + horizon`. The performance at each time step is measured and returned.
  
      Parameters
      ----------
      dataset
          A sequential time series.
      model
          A forecaster.
      metric
          A regression metric.
      horizon
      agg_func
      grace_period
          Initial period during which the metric is not updated. This is to fairly evaluate models
          which need a warming up period to start producing meaningful forecasts. The value of this
          parameter is equal to the horizon by default.
  
      """
  
      horizon_metric = None
      steps = iter_evaluate(
          dataset, model, metric, horizon, agg_func, grace_period
      )
      for *_, horizon_metric in steps:
          pass
  
      return horizon_metric
  
file_path: river/river/time_series/evaluate.py
imports: from __future__ import annotations
  import collections
  import numbers
  import typing
  from river import base, metrics, time_series
label_desc: Use image node_id 3 for calling a global function with example usage: evaluate(dataset, model, metric, horizon, agg_func, grace_period) and returns: horizon_metric