Question: Part 7 . A Use the cell below to define a function train _ logreg ( ) . The function should accept four parameters named

Part 7.A
Use the cell below to define a function train_logreg(). The function should accept four parameters named X, y, alpha, and n. Descriptions of the parameters are as follows:
X is expected to be a 2D feature array.
y is expected to be a 1D label array.
alpha is expected to be a learning rate.
steps is the number of iterations of gradient descent to perform during training.
The function should apply gradient descent to determine optimal parameters for a logistic regression model. An outline of the steps that the function should perform is provided below.
The function add_ones() should be used to create an "extended" feature matrix XE.
A coeficient array named betas should be created with all values initialized to zero. The following code can be used for this task: betas = np.zeros(XE.shape[1])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!