import numpy as np import matplotlib.pyplot as plt
np.random.seed(42)
defMSEStep(X, y, W, b, learn_rate = 0.001): """ This function implements the gradient descent step for squared error as a performance metric. Parameters X : array of predictor features y : array of outcome values W : predictor feature coefficients b : regression function intercept learn_rate : learning rate Returns W_new : predictor feature coefficients following gradient descent step b_new : intercept following gradient descent step """ # compute errors # the squared trick formula y_pred = np.matmul(X, W) + b #Attention:the...
import numpy as np import matplotlib.pyplot as plt
np.random.seed(42)
defMSEStep(X, y, W, b, learn_rate = 0.001): """ This function implements the gradient descent step for squared error as a performance metric. Parameters X : array of predictor features y : array of outcome values W : predictor feature coefficients b : regression function intercept learn_rate : learning rate Returns W_new : predictor feature coefficients following gradient descent step b_new : intercept following gradient descent step """ # compute errors # the squared trick formula y_pred = np.matmul(X, W) + b #Attention:the...