in afa/core.py [0:0]
def calc_smape(y, yp, axis=0, smooth=True):
"""Calculate the symmetric mean absolute percentage error (sMAPE).
sMAPE is calulated as follows:
sMAPE = Σ|y - yp| / Σ(y + yp)
where, 0.0 <= sMAPE <= 1.0 (lower is better)
"""
try:
eps = 1 / y.shape[0]
if smooth:
y2, yp2 = y + eps, yp + eps
else:
y2, yp2 = y, yp
try:
smape = np.divide(np.nansum(np.abs(y2 - yp2), axis=axis),
np.nansum(y2 + yp2, axis=axis))
except ZeroDivisionError:
smape = 0.0
except ZeroDivisionError:
return np.nan
return np.round(smape, 4)