Binary cross-entropy loss
Your task
Compute the binary cross-entropy (log loss) of a classifier. Given y_true (labels 0/1) and y_prob (predicted probabilities of the positive class, each in [0,1]), the log loss is the negative mean over samples of y*ln(p) + (1-y)*ln(1-p). To avoid log(0), clip every probability into the range [eps, 1-eps] with eps = 1e-15 before taking logs. Return the mean log loss rounded to 6 decimal places. The lists are non-empty and equal length, up to 10^5 elements.
Examples
log_loss(y_true: list[int], y_prob: list[float]) -> floatExample 1
Input
log_loss([1, 0], [0.9, 0.1])Output
0.105361