code: def iter_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,
  ):
      """Evaluates the performance of a forecaster on a time series dataset and yields results.
  
      This does exactly the same as `evaluate.progressive_val_score`. The only difference is that
      this function returns an iterator, yielding results at every step. This can be useful if you
      want to have control over what you do with the results. For instance, you might want to plot
      the results.
  
      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 = (
          time_series.HorizonAggMetric(metric, agg_func)
          if agg_func
          else time_series.HorizonMetric(metric)
      )
      steps = _iter_with_horizon(dataset, horizon)
  
      grace_period = horizon if grace_period is None else grace_period
      for _ in range(grace_period):
          x, y, x_horizon, y_horizon = next(steps)
          model.learn_one(y=y, x=x)  # type: ignore
  
      for x, y, x_horizon, y_horizon in steps:
          y_pred = model.forecast(horizon, xs=x_horizon)
          horizon_metric.update(y_horizon, y_pred)
          model.learn_one(y=y, x=x)  # type: ignore
          yield x, y, y_pred, 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 2 for calling a global function with example usage: iter_evaluate(dataset, model, metric, horizon, agg_func, grace_period) without return types