{
  "schema": "ml-prep/item@1",
  "item": {
    "id": "original-ml-pca",
    "area": "machine-learning",
    "topic": "dimensionality-reduction",
    "origin": "original",
    "title": "PCA direction and explained variance",
    "skills": [
      "pca-objective",
      "centering",
      "covariance-eigendecomposition",
      "explained-variance"
    ],
    "priority": "core",
    "difficulty": "easy",
    "estimated_minutes": 7,
    "prerequisites": [
      "eigenvalues"
    ],
    "prompt": "A centered two-dimensional dataset has covariance $\\operatorname{diag}(9,1)$. Give the first principal direction, the fraction of variance it explains, and the reconstruction-error variance after projection to one dimension. Explain why PCA should first center raw observations.\n",
    "answer": "The first direction is $(1,0)$, it explains\n\n$$\\frac{9}{9+1}=0.9$$\n\nof the variance, and the discarded, or reconstruction-error, variance is $1$. Centering removes the mean offset so that the principal directions describe variation around the mean rather than the mean location itself.\n",
    "check": {
      "kind": "numeric",
      "id": "original-ml-pca",
      "values": [
        1,
        0,
        0.9,
        1
      ]
    }
  }
}