We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
medium
end_to_end
Polynomial Regression
Implement polynomial regression by first constructing polynomial features, then applying a linear model.
Given scalar inputs x and a degree d, construct features:
$\phi(x) = [1, x, x^2, ..., x^d]$
Then predict: $\hat{y} = \phi(x) \cdot w$
And compute MSE loss: $L = \frac{1}{N} \sum (y - \hat{y})^2$
Input:
-
x: input tensor of shape(N,) -
w: weight vector of shape(d+1,)for polynomial of degreed -
y: target values of shape(N,)
Output: A dict with “prediction” (shape (N,)) and “loss” (scalar).
Hints
polynomial
regression
feature-engineering
Sign in to attempt this problem and view the solution.