Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def logloss(y, p):
"""Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
"""
p[p < EPS] = EPS
p[p > 1 - EPS] = 1 - EPS
return log_loss(y, p)
def mape(y, p):
"""Mean Absolute Percentage Error (MAPE).
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
e (numpy.float64): MAPE
"""
filt = np.abs(y) > EPS
return np.mean(np.abs(1 - p[filt] / y[filt]))