{
  "schema": "ml-prep/item@1",
  "item": {
    "id": "original-ml-regression",
    "area": "machine-learning",
    "topic": "regression",
    "origin": "original",
    "title": "Linear regression objective and gradient",
    "skills": [
      "linear-regression",
      "squared-loss",
      "regression-gradient"
    ],
    "priority": "foundation",
    "difficulty": "easy",
    "estimated_minutes": 8,
    "prerequisites": [
      "matrix-multiplication",
      "derivatives"
    ],
    "prompt": "For $X=\\begin{bmatrix}1&0\\\\1&1\\end{bmatrix}$, $\\mathbf{y}=(1,3)$, and $\\mathbf{w}=(0,0)$, use\n\n$$L(\\mathbf{w})=\\frac{1}{2}\\lVert X\\mathbf{w}-\\mathbf{y}\\rVert_2^2.$$\n\nCompute $L$, its gradient, and one gradient-descent update with learning rate $0.1$.\n",
    "answer": "$L=5$. The gradient is\n\n$$\\nabla_{\\mathbf{w}}L=X^\\top(X\\mathbf{w}-\\mathbf{y})=(-4,-3),$$\n\nso the update is $\\mathbf{w}=(0.4,0.3)$.\n",
    "check": {
      "kind": "numeric",
      "id": "original-ml-regression",
      "values": [
        5,
        -4,
        -3,
        0.4,
        0.3
      ]
    }
  }
}