# xskillscore.smape

xskillscore.smape(a, b, dim=None, weights=None, skipna=False, keep_attrs=False)

Symmetric Mean Absolute Percentage Error.

$\mathrm{SMAPE} = \frac{1}{n} \sum_{i=1}^{n} \frac{ \vert a_{i} - b_{i} \vert } { \vert a_{i} \vert + \vert b_{i} \vert }$

Note

Percent error is reported as decimal percent. I.e., a value of 1 is 100%.

Parameters
• a (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function. (Truth which will be divided by)

• b (xarray.Dataset or xarray.DataArray) – Labeled array(s) over which to apply the function.

• dim (str, list) – The dimension(s) to apply the smape along. Note that this dimension will be reduced as a result. Defaults to None reducing all dimensions.

• weights (xarray.Dataset or xarray.DataArray or None) – Weights matching dimensions of dim to apply during the function.

• skipna (bool) – If True, skip NaNs when computing function.

• keep_attrs (bool) – If True, the attributes (attrs) will be copied from the first input to the new one. If False (default), the new object will be returned without attributes.

Returns

Symmetric Mean Absolute Percentage Error.

Return type

References

https://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error

Examples

>>> a = xr.DataArray(np.random.rand(5, 3, 3), dims=['time', 'x', 'y'])
>>> b = xr.DataArray(np.random.rand(5, 3, 3), dims=['time', 'x', 'y'])
>>> xs.smape(a, b, dim='time')
<xarray.DataArray (x: 3, y: 3)>
array([[0.35591619, 0.43662087, 0.55372571],
[0.1864336 , 0.45831965, 0.38473469],
[0.58730494, 0.18081757, 0.14960832]])
Dimensions without coordinates: x, y