ex5.m
Part 2: Regularized Linear Regression Cost
-
Compute the cost and gradient of regularized linear regression for a particular choice of theta.
1 | % cost function |
Part 4: Train Linear Regression
-
In this part, we set regularization parameter λ to zero.
- Because our current implementation of linear regression is trying to fit a 2-dimensional θ, regularization will not be incredibly helpful for a θ of such low dimension.
1 | % Initialize Theta |
Part 5: Learning Curve for Linear Regression
-
Fill in this function to return training errors in error_train and the cross validation errors in error_val.
1 | for i = 1: m |
Part 6: Feature Mapping for Polynomial Regression
-
Given a vector X, return a matrix X_poly where the p-th column of X contains the values of X to the p-th power.
1 | m = size(X, 1); |
Part 8: Validation for Selecting Lambda
-
Fill in this function to return training errors in error_train and the validation errors in error_val.
1 | for i = 1: length(lambda_vec) |