Loading...
Compute the binary cross-entropy loss (log loss) for a set of predictions.
Given true labels yi∈{0,1} and predicted probabilities y^i∈(0,1):
BCE=−n1∑i=1n[yilog(y^i)+(1−yi)log(1−y^i)]
To avoid log(0), clip predictions to the range [ϵ,1−ϵ] where ϵ=10−7.
Return the loss rounded to 4 decimal places.
y_true = [1, 0, 1] y_pred = [0.9, 0.1, 0.8]
0.1446