mae#
- class braintools.fit.losses.mae(prediction, target)#
Compute the mean absolute error between two time series.
\[\mathrm{MAE} = \frac{1}{M} \sum_{i=1}^{M} |\hat y_i - y_i|.\]- Parameters:
- Returns:
Scalar MAE; for Quantity inputs the plain magnitude in the prediction’s unit.
- Return type:
Array- Raises:
ValueError – If the shapes differ.
TypeError – If only one input carries units.
brainunit.UnitMismatchError – If the units have different dimensions.
Notes
Works under
jax.jitandjax.vmap; differentiable except whereprediction == target(JAX uses the subgradient 0 there).Examples
>>> import jax.numpy as jnp >>> from braintools.fit import losses >>> float(losses.mae(jnp.array([1., -1., 4.]), jnp.zeros(3))) 2.0