Solution (source code)

= Solution

For conditionally independent binary labels, the <likelihood> is
$$
L(\mathbf w)=\prod_{i=1}^{m} h_i^{y_i}(1-h_i)^{1-y_i},\qquad
h_i=h(\mathbf z_i;\mathbf w).
$$
Maximizing it is equivalent to minimizing its negative <log-likelihood>, the mean <binary cross-entropy>:
$$
\boxed{\mathcal L(\mathbf w)=-\frac1m\sum_{i=1}^{m}
[y_i\log h_i+(1-y_i)\log(1-h_i)].}
$$
It is the loss implied by a <Bernoulli distribution> for each target, penalizes confident errors strongly and is convex in the linear-logistic parameters. For numerical stability, each contribution can be evaluated as $\log(1+e^{u_i})-y_i u_i$ using a stable softplus implementation.

The 10:90 class imbalance does not invalidate this <likelihood>. Class weighting or resampling may be useful if errors have unequal costs, but changes the training objective and potentially the interpretation of fitted <probabilities>. Optional <ridge regression> adds $\lambda\|\mathbf w\|^2/2$, usually excluding the intercept, to control overly large weights or complete separation.