Ridge Regression in Closed Form
~15 mincode completion
Implement ridge_closed_form(X, y, lam) returning [b,w1,…,wd], bias first. Use .
Where this shows up
~15 min
••••••••••••••••
8 employers weight this skill
4 frontier labs, 2 big tech firms, 1 autonomy company, 1 enterprise vendor. Top match scores 78.
Python
import numpy as np
def ridge_closed_form(X, y, lam):
"""
Ridge regression with an unpenalized bias, solved exactly.
Args:
X: array of shape (n, d)
y: array of shape (n,)
lam: penalty strength lambda >= 0, on the sum-of-squares loss
Returns:
array of shape (d + 1,): [b, w_1, ..., w_d]
"""
# YOUR CODE HERE
pass