Question: Part 7 . A Use the cell below to define a function train _ logreg ( ) . The function should accept four parameters named
Part A
Use the cell below to define a function trainlogreg 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 D feature array.
y is expected to be a D 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 addones 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 npzerosXEshape
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
