Solve the logistic regression problem on a GPU. Given a feature matrix \(X\) of size \(n\_samples \times n\_features\) and a binary target vector \(y\) of size \(n\_samples\) (containing only 0s and 1s), compute the coefficient vector \(\beta\) that maximizes the log-likelihood: \[ \max_{\beta} \sum_{i=1}^{n} \left[ y_i \log(p_i) + (1-y_i) \log(1-p_i) \right] \] where \(p_i = \sigma(X_i^T \beta)\) and \(\sigma(z) = \frac{1}{1 + e^{-z}}\) is the sigmoid function.
solve function signature must remain unchangedbeta vectory contains only binary values (0 and 1)
Input:
\(X\) (samples × features):
\[
\begin{bmatrix}
2.0 & 1.0 \\
1.0 & 2.0 \\
3.0 & 3.0 \\
1.5 & 2.5 \\
-1.0 & -2.0 \\
-2.0 & -1.0 \\
-1.5 & -2.5 \\
-3.0 & -3.0
\end{bmatrix}
\]
\(y\):
\[
\begin{bmatrix}
1 \\
1 \\
1 \\
0 \\
0 \\
0 \\
1 \\
0
\end{bmatrix}
\]
Output:
\(\beta\):
\[
\begin{bmatrix}
2.26 \\
-1.29
\end{bmatrix}
\]
n_samples ≤ 100,000n_features ≤ 1,000n_samples ≥ n_featuresX ≤ 10.0y contains only binary values: 0 or 1n_features = 8, n_samples = 16