Question: Implement the function Logistic _ Regression _ via _ GD ( P , y , lr ) : Input: an n p array ' P
Implement the function LogisticRegressionviaGDPylr:
Input: an array of rows and columns, a label vector of entries and learning rate parameter Ir
Output: The function computes the output vector and which minimzes the logistic regression cost function on and
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 gradL which is the true empirical loss' gradient
def sigmoidz:
return
# For now, ignore the lambda, you will need it later
def LogisticRegressionviaGD lamda :
# Implement here
Implement the function Predictwbp:
Input: an input vector which represents a sample, a vector numpy and a number
Output: the class prediction for of the logistic regression model defined by and
Note: It is your choice if use predictions of or Make sure to adjust your choice to the true labels for comparison
def predict :
# Implement here
Call 'LogisticRegressionviaGDPylr where and 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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
