Ridge Regression in Closed Form

~15 mincode completion

Implement ridge_closed_form(X, y, lam) returning , 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
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.