in src/minmaxML.py [0:0]
def compute_logloss(y_true, y_pred_proba, eps=1e-15):
"""
:param y_true: True labels (0/1)
:param y_pred_proba: Predicted label probabilities
:param eps: epsilon for rounding (smallest prob is eps, largest is 1-eps)
:return: Array of individual log-losses for each element
"""
# If we have an array of [neg_prob, pos_prob], then we only need the pos_probs, since neg_prob = 1 - pos_prob
if len(y_pred_proba.shape) > 1 and y_pred_proba.shape[1] == 2:
y_pred_proba = y_pred_proba[:, 1]
# Clip the array within epsilon for numerical precision reasons
y_pred_proba = np.clip(y_pred_proba, eps, 1 - eps)
# The first term only contributes when the label is 1, and the second only contributes when the label is 0
return (y_true * (-np.log(y_pred_proba))) + ((1 - y_true) * (-np.log(1 - y_pred_proba)))