Question: Implement the function Logistic _ Regression _ via _ GD ( P , y , lr ) : Input: an n p array ' P

Implement the function Logistic_Regression_via_GD(P,y,lr):
Input: an np array 'P' of 'n' rows and 'd' columns, a label vector 'y' of 'n' entries and learning rate parameter 'Ir'.
Output: The function computes the output vector 'w'(and 'b') which minimzes the logistic regression cost function on 'P' and 'y'.
The implementation should be fully yours. Don't use library implementation!
It should be done by implementing Gradient descent (with 'Ir' as the learning rate) to solve logistic regression.
Tip: The gradients may be large, you can use 1ngradL (which is the true empirical loss' gradient)
[] def sigmoid(z):
return 11+np.exp(-z)
# For now, ignore the lambda, you will need it later
def Logistic_Regression_via_GD (P,y,lr, lamda =0 :
# Implement here
Implement the function Predict(w,b,p):
Input: an input vector x which represents a sample, a vector (numpy)'w' and a number 'b'.
Output: the class prediction for 'p' of the logistic regression model defined by 'w' and 'b'.
Note: It is your choice if use predictions of 1-1 or 10. Make sure to adjust your choice to the true labels (for comparison).
[] def predict (x,w,b) :
# Implement here
Call 'Logistic_Regression_via_GD(Py,lr)', where 'P' and 'y' are the training data and the corresponding labels.
Try to find the best Ir for the learning task.
[] # Implement here
Run the model on the test data, print the accuracy and plot hyperplane on the test data using 'plot' as defined above.
[] # Implement here
 Implement the function Logistic_Regression_via_GD(P,y,lr): Input: an np array 'P' of 'n'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!