Complete the following tasks¶
- Complete the following function
def polyfit(x,y,degree,delta):
"""
Fits a polynomial to 2D data (x,y)
Arguments:
x, y -- x and y data points
degree -- polynomial degree
delta -- regularization parameter
Returns:
Fitted parameters theta, where y = p(x) = \sum_{i=0}^degree \theta_i x^i
"""
- Complete the following function
def polyeval(theta, x):
"""
Evaluates a 1D polynomial (i.e., fitted to 2D points (x,y))
Arguments:
x -- points at which we want to evaluate the polynomial
theta -- polynomial parameters
Returns:
p(x) -- where p(x) = \sum_{i=0}^degree \theta_i x^i
"""
- Write down a routine that performs polygon fitting using gradient descent. Recall that the least squares cost is $J(\theta) = (\mathbf{X} \theta - \mathbf{Y})^T(\mathbf{X} \theta - \mathbf{Y})$.