D ef logistic _ _ regression ( ( X , , y , , max _ _
Fantastic news! We've Found the answer you've been seeking!
Question:
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.
Related Book For
Corporate Finance
ISBN: 9781265533199
13th International Edition
Authors: Stephen Ross, Randolph Westerfield, Jeffrey Jaffe
Posted Date: