HorizonAggMetric¶
Same as HorizonMetric
, but aggregates the result based on an provided function.
This allows, for instance, to measure the average performance of a forecasting model along the horizon.
Parameters¶
-
metric
Type → metrics.base.RegressionMetric
A regression metric.
-
agg_func
Type → typing.Callable[[list[float]], float]
A function that takes as input a list of floats and outputs a single float. You may want to
min
,max
, as well asstatistics.mean
andstatistics.median
.
Examples¶
This is used internally by the time_series.evaluate
function when you pass an agg_func
.
import statistics
from river import datasets
from river import metrics
from river import time_series
metric = time_series.evaluate(
dataset=datasets.AirlinePassengers(),
model=time_series.HoltWinters(alpha=0.1),
metric=metrics.MAE(),
agg_func=statistics.mean,
horizon=4
)
metric
mean(MAE): 42.901748
Methods¶
get
Return the current performance along the horizon.
Returns
list[float]: The current performance.
update
Update the metric at each step along the horizon.
Parameters
- y_true — 'list[Number]'
- y_pred — 'list[Number]'
Returns
ForecastingMetric: self