← 返回 pinterest 的题目列表Logistic Regression Implementation
类型:online_judge
Implement the training process of logistic regression. Given a feature matrix X and target vector y, compute the weight vector W for the model. Use gradient descent to minimize the logistic regression loss function. Input: A feature matrix X, a numpy array of shape (n, m), and target vector y, a numpy array of shape (n,). Output: The weight vector W. Assume X and y are given and data is 2D, learning rate is 0.01, and the number of iterations is 1000.
Example
Input
np.array([[0.5], [0.75], [1.0], [1.25], [1.5], [1.75], [2.0], [2.25], [2.5]])
np.array([0, 0, 0, 1, 1, 1, 1, 1, 1])