costFunctionReg <- function(theta, X, y, lambda){ # Computes cost for logistic regression with regularization # # J <- costFunctionReg(theta, X, y, lambda) computes the cost of using # theta as the parameter for regularized logistic regression # Initialize some useful values m <- length(y) # number of training examples # ====================== YOUR CODE HERE ====================== # Instructions: Compute the cost of a particular choice of theta. # You should set J to the cost. # ============================================================ return(J) }