Answered step by step
Verified Expert Solution
Question
1 Approved Answer
D ef logistic _ _ regression ( ( X , , y , , max _ _ iter, alpha ) ) : '
Def logisticregressionX y maxiter, alpha:
Trains the logistic regression classifier on data X and labels y using gradient descent for maxiter iterations with learning rate alpha.
Returns the weight vector, bias term, and losses at each iteration AFTER updating the weight vector and bias.
Input:
X: data matrix of shape nxd
y: ndimensional vector of data labels or
maxiter: number of iterations of gradient descent to perform
alpha: learning rate for each gradient descent step
Output:
w b losses
w: ddimensional weight vector
b: scalar bias term
losses: maxiterdimensional vector containing negative log likelihood values AFTER a gradient descent in each iteration
n d Xshape
w npzerosd
b
losses npzerosmaxiter
for step in rangemaxiter:
# YOUR CODE HERE.
Step by Step Solution
★★★★★
3.44 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
python import numpy as np def logisticregressionX y maxiter alpha Trains the logistic regression cla...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