Question: Carry out a logistic regression analysis on a (partial) wine data set classification problem. The data can be loaded using the following code. The model
Carry out a logistic regression analysis on a (partial) wine data set classification problem. The data can be loaded using the following code.

The model matrix has three features, including the constant feature. Instead of using Newton's method (5.39) to estimate \(\boldsymbol{\beta}\), implement a simple gradient descent procedure \[ \boldsymbol{\beta}_{t}=\boldsymbol{\beta}_{t-1}-\alpha abla r_{\tau}\left(\boldsymbol{\beta}_{t-1}\right) \]
with learning rate \(\alpha=0.0001\), and run it for \(10^{6}\) steps. Your procedure should deliver three coefficients; one for the intercept and the rest for the explanatory variables. Solve the same problem using the Logit method of statsmodels.api and compare the results.
from sklearn import datasets import numpy as np data datasets. load wine (). X data.data[:, [9, 10]] y np.array (data. target 1, dtype=np.uint) X = np.append (np.ones (len (X)).reshape(-1, 1), X, axis=1)
Step by Step Solution
3.45 Rating (152 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
