Sigmoid and log loss

Mediumexplogvectorised formulas· 20 XP

A logistic regression model outputs raw scores. The sigmoid, 1 / (1 + exp(-z)), turns them into probabilities, and log loss measures how good those probabilities are:

log loss = -mean( y × log(p) + (1 - y) × log(1 - p) )

The scores and labels are illustrative.

Turn scores into probabilities with the sigmoid, then store the log loss against y, rounded to 4 decimals.

Expected answer

Store your answer in result.

Hints, the later steps and the answer come with Pro.

import numpy as np

scores = np.array([2.0, -1.0, 0.5, -2.5, 1.5, 0.0])
y = np.array([1, 0, 1, 0, 0, 1])
result = ...