solarforecastarbiter.metrics.deterministic.mean_absolute¶
-
solarforecastarbiter.metrics.deterministic.
mean_absolute
(obs, fx, error_fnc=<function error>)[source]¶ Mean absolute error (MAE).
\[\text{MAE} = 1/n \sum_{i=1}^n |\text{fx}_i - \text{obs}_i|\]Parameters: - obs ((n,) array-like) – Observed values.
- fx ((n,) array-like) – Forecasted values.
- error_fnc (function) – A function that returns the error, default fx - obs. First argument is obs, second argument is fx.
Returns: mae (float) – The MAE of the forecast.
Examples
Standard MAE: >>> obs = np.array([1, 2, 3, 4]) >>> fx = np.array([2, 2.04, 2, 3.96]) >>> mean_absolute(obs, fx) 0.52
MAE with a deadband: >>> error_fnc = partial(error_deadband, deadband=0.05) >>> mean_absolute(obs, fx, error_fnc=error_fnc) 0.5