Solution (source code)

= Solution

Initialize the weights, evaluate the feature matrix and repeat <gradient descent> updates until the loss or gradient stabilizes. If $\widetilde{\mathbf z}_i=(1,\mathbf z_i)$ includes the intercept, then
$$
\nabla\mathcal L=\frac1m\sum_i(h_i-y_i)\widetilde{\mathbf z}_i,
\qquad
\mathbf w\leftarrow\mathbf w-\eta\nabla\mathcal L.
$$
A positive step size $\eta$ chosen by a convergence rule or <line search> gives a practical optimization algorithm. Mini-batch updates or a Newton-type method are alternatives. Fit feature scaling, choose regularization and choose any nonstandard threshold using training or validation data, then freeze the procedure before using the held-out test set.

For $M$ held-out examples, set $\widehat Y_i=\mathbf1\{h(\mathbf Z_i;\widehat{\mathbf w})\geq t\}$, with $t=0.5$ unless selected otherwise. The requested <classification accuracy> is
$$
\boxed{\mathrm{accuracy}=\frac1M\sum_{i=1}^M\mathbf1\{\widehat Y_i=Y_i\}
=\frac{TP+TN}{TP+TN+FP+FN}.}
$$
\b[Always predicting the majority class already gives about 90% accuracy.] Report a <confusion matrix>, <classification recall> and <classification precision> as well, especially for the minority class. A <precision-recall curve> shows the threshold tradeoff without confusing high majority-class accuracy with successful minority-class detection. No numerical test accuracy can be calculated without the held-out predictions and labels.