← Playground← 놀이터

PRISM · Machine Learning PlaygroundPRISM · 머신러닝 놀이터

Principal Component Analysis주성분 분석
Find the direction of maximum variance — unsupervised dimensionality reduction분산이 최대가 되는 방향을 찾아라 — 비지도 차원 축소

Total variance tr(Σ) = projected + residual =총 분산 tr(Σ) = 투영 + 잔차 =
Data데이터 Mean x̄평균 x̄ Direction w(θ)방향 w(θ) Projected point투영점 Residual잔차 PC1 (±2√λ₁) PC2 (±2√λ₂)
Projected variance wᵀΣw vs direction θ — the maximum is PC1(λ₁), the minimum is PC2(λ₂)투영 분산 wᵀΣw vs 방향 θ — 최대점이 PC1(λ₁), 최소점이 PC2(λ₂)
w(θ)
Direction being searched탐색 중인 방향
Projected variance wᵀΣw투영 분산 wᵀΣw
Reconstruction error재구성 오차
Explained ratio설명 비율

Variance decomposition when projecting onto an arbitrary direction임의 방향에 투영했을 때의 분산 분해

PC1
First principal component첫 번째 주성분
λ₁
Direction angle θ₁방향각 θ₁
Explained ratio설명 비율

Maximum of wᵀΣw — first eigenvectorwᵀΣw의 최대 — 첫 고유벡터

PC2
Second principal component두 번째 주성분
λ₂
Direction angle방향각
Explained ratio설명 비율

Orthogonal to PC1 — remaining variancePC1과 직교 — 남은 분산

Formulas수식
$$\bar{\mathbf x}=\tfrac1n\textstyle\sum_i \mathbf x_i,\qquad \Sigma=\tfrac1n\textstyle\sum_i(\mathbf x_i-\bar{\mathbf x})(\mathbf x_i-\bar{\mathbf x})^\top$$ $$\max_{\|\mathbf w\|=1}\ \mathbf w^\top\Sigma\,\mathbf w\ \Longrightarrow\ \Sigma\mathbf w=\lambda\mathbf w\quad(\text{Lagrange multiplier }\lambda)$$ $$\underbrace{\mathbf w^\top\Sigma\,\mathbf w}_{\text{projected var}}+\underbrace{\tfrac1n\textstyle\sum_i\|\mathbf x_i-\hat{\mathbf x}_i\|^2}_{\text{reconstruction error}}=\operatorname{tr}(\Sigma),\qquad \hat{\mathbf x}_i=\bar{\mathbf x}+\mathbf w\mathbf w^\top(\mathbf x_i-\bar{\mathbf x})$$ $$\text{explained ratio}=\frac{\lambda_1}{\lambda_1+\lambda_2},\qquad \mathbf w(\theta)=(\cos\theta,\ \sin\theta)^\top$$
What to watch수업 관찰 포인트
  1. Press Scan θ and the projected variance traces a sinusoid — the direction of the maximum is PC1 and its value is λ₁, while the minimum 90° away is PC2(λ₂). “Finding” the eigenvectors is exactly optimizing this curve.θ 스캔을 누르면 투영 분산이 사인 곡선을 그린다 — 최대점의 방향이 PC1이고 그 값이 λ₁, 90° 떨어진 최소점이 PC2(λ₂). 고유벡터를 “찾는” 일이 곧 이 곡선의 최적화다.
  2. At any θ, projected variance + reconstruction error = tr(Σ) (Pythagoras). Maximizing variance and minimizing reconstruction error are two expressions of the same problem.어느 θ에서든 투영 분산 + 재구성 오차 = tr(Σ) (피타고라스). 분산 최대화와 재구성 오차 최소화는 같은 문제의 두 표현이다.
  3. Raise σ₂ close to σ₁ (isotropy) and the curve flattens with the explained ratio near 50% — the principal direction becomes essentially meaningless, and adding just a few points swings the axes a lot.σ₂를 σ₁에 가깝게 올리면(등방성) 곡선이 평평해지고 설명 비율이 50%로 — 주성분 방향이 사실상 무의미해지고, 점 몇 개만 추가해도 축이 크게 돈다.
  4. Try clicking to add a single far-off outlier — being variance-based, the axes get pulled toward it sensitively (PCA's outlier sensitivity).멀리 이상치 하나를 클릭해 추가해 보라 — 분산 기반이라 축이 민감하게 끌려간다 (PCA의 이상치 민감성).
  5. Note that there are no labels at all — PCA is unsupervised learning that only looks at the spread of the data.라벨이 전혀 없다는 점에 주목 — PCA는 데이터의 퍼진 모양만 보는 비지도 학습이다.