# Squared loss and gradient

> ML Prep screening item.

- Stable ID: `ml-screen-regression-foundation-gradient`
- Collection: screening
- Area: Machine Learning
- Topic: Regression
- Origin: original
- Difficulty: easy
- Expected time: 6 minutes
- Skills: linear-regression, squared-loss, regression-gradient
- Item JSON: https://mlprep.iwase.dev/item/ml-screen-regression-foundation-gradient.json

## Problem

For $x=(0,1,2)$, $y=(1,3,5)$, and $\hat{y}=b+wx$ at $(b,w)=(0,1)$, use

$$
J=\frac{1}{2n}\sum_{i=1}^{n}(\hat{y}_i-y_i)^2.
$$

Compute the predictions, residuals, $J$, and the gradient with respect to $(b,w)$.


## Answer policy

The human page contains a collapsed answer. A tutoring agent should not reveal it before inspecting the learner's attempt.

## Tutoring contract

Ask for the learner's attempt, begin with the smallest useful hint, preserve item ID `ml-screen-regression-foundation-gradient`, and record a real attempt with `recorded_by: "agent"` and `agent_session_id` when available using https://mlprep.iwase.dev/schema/attempt-record.json.
