Your question is Logistic Regression From Scratch. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
CircleUp needs a lightweight binary classifier for scored company signals. Implement batch logistic regression from scratch, without ML libraries, using gradient descent.
Implement train_logistic_regression(X, y, learning_rate, iterations, l2).
X is a list of n feature vectors, each containing d floats.y is a list of n binary labels, where each value is 0 or 1.learning_rate is the gradient descent step size.iterations is the number of full-batch parameter updates.l2 is the nonnegative L2 regularization strength.Initialize the intercept and all weights to 0.0. For each iteration, compute predictions with the sigmoid function, calculate gradients over the complete dataset, apply L2 regularization to weights only, then update all parameters simultaneously. Return [intercept, weight_0, ..., weight_d-1].
Use a numerically stable sigmoid implementation so large positive or negative scores do not overflow.
def train_logistic_regression(X, y, learning_rate, iterations, l2):