Tell me about how you would implement a logistic regression model from data, and then iterate on it to improve performance.
Implement your answer as a pure function that trains binary logistic regression using batch gradient descent and returns predicted labels for the training rows. Include a learning rate, epoch count, and L2 regularization parameter.
Input X is a non-empty list of numeric feature rows and y is a binary-label list with matching length. Return a list of integer predictions in the same order as X.
def logistic_regression(X, y, learning_rate, epochs, l2):