Train a binary logistic regression classifier using gradient descent. Implement the training loop and return the learned parameters (w, b).
Model:
p=σ(Xw+b)=1+e−(Xw+b)1Loss (Binary Cross-Entropy):
L=−N1i=1∑N[yilogpi+(1−yi)log(1−pi)]Input: X = [[0], [1], [2], [3]], y = [0, 0, 1, 1], lr = 0.1, steps = 500
Output: ([2.5272], -3.4307)
Compute grad_w with X.T @ (p - y) / len(y) and grad_b with np.mean(p - y).
Update both parameters with the learning rate during every iteration.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number
Train a binary logistic regression classifier using gradient descent. Implement the training loop and return the learned parameters (w, b).
Model:
p=σ(Xw+b)=1+e−(Xw+b)1Loss (Binary Cross-Entropy):
L=−N1i=1∑N[yilogpi+(1−yi)log(1−pi)]Input: X = [[0], [1], [2], [3]], y = [0, 0, 1, 1], lr = 0.1, steps = 500
Output: ([2.5272], -3.4307)
Compute grad_w with X.T @ (p - y) / len(y) and grad_b with np.mean(p - y).
Update both parameters with the learning rate during every iteration.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Accepts: number