Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started