[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,89 +2,147 @@
|
||||
id: wiki-2026-0508-multivariate-analysis
|
||||
title: Multivariate Analysis
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [MATH-MVA-001]
|
||||
aliases: [MVA, Multivariate Statistics]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: ["Statistics|[Statistics", math, multivariate-Analysis, pca, mva, data-science]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [statistics, dimensionality-reduction, multivariate]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-26
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: Python
|
||||
framework: scikit-learn/statsmodels
|
||||
---
|
||||
|
||||
# Multivariate Analysis (다변량 분석)
|
||||
# Multivariate Analysis
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "단일 변수의 관찰을 넘어, 변수들 사이의 복잡한 얽힘과 상호작용 속에서 데이터의 진짜 형상을 발견하라" — 둘 이상의 변수가 동시에 가지는 통계적 특성과 상관관계를 분석하여, 데이터 내의 숨겨진 패턴이나 구조를 파악하는 통계적 방법론의 총칭.
|
||||
## 매 한 줄
|
||||
> **"매 multiple correlated variables 매 동시에"**. 매 MVA는 covariance·correlation matrix를 base로 PCA/FA/CCA/MANOVA/discriminant analysis 매 통합, 매 2026 ML 시대에도 매 EDA·feature engineering·biostatistics·marketing research에서 매 indispensable foundation.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **추출된 패턴:** "Dimensionality Reduction and Structural Discovery" — 변수들 사이의 공분산(Covariance)과 상관계수를 분석하여, 데이터의 흩어짐을 가장 잘 설명하는 주성분을 찾거나(PCA) 유사한 집단으로 묶는(Clustering) 등 고차원 데이터를 저차원의 핵심 구조로 요약하는 패턴.
|
||||
- **주요 기법:**
|
||||
- **PCA (주성분 분석):** 데이터의 분산을 최대한 보존하며 차원 축소.
|
||||
- **Factor Analysis (요인 분석):** 관측된 변수들 뒤에 숨겨진 잠재 요인 추출.
|
||||
- **MANOVA (다변량 분산 분석):** 여러 종속 변수에 대한 집단 간 차이 검정.
|
||||
- **Canonical Correlation:** 두 변수 집단 사이의 상관관계 최대화.
|
||||
- **의의:** 변수가 수백, 수천 개에 달하는 현대 빅데이터 환경에서 데이터의 중복성을 제거하고 핵심적인 인사이트를 도출하기 위한 필수적인 통계적 토대.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 선형적인 관계 분석에 치중하던 과거와 달리, 이제는 커널 기법이나 오토인코더(Autoencoder)와 같은 신경망 기술과 결합하여 비선형적인 다변량 관계까지 정밀하게 포착하는 방향으로 진화함.
|
||||
- **정책 변화:** Antigravity 프로젝트는 에이전트의 다양한 성능 지표(응답 속도, 정확도, 토큰 사용량 등) 사이의 복합적인 상관관계를 분석하여 전체적인 시스템 효율을 최적화할 때 다변량 분석 기법을 활용함.
|
||||
### 매 covariance matrix Σ
|
||||
- Σᵢⱼ = E[(Xᵢ - μᵢ)(Xⱼ - μⱼ)].
|
||||
- Eigendecomposition Σ = QΛQᵀ가 매 모든 multivariate 기법의 backbone.
|
||||
- Sample S = (1/(n-1)) XᶜᵀXᶜ.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Principal-Component-Analysis|Principal-Component-Analysis]]-PCA, [[Linear-Discriminant-Analysis|Linear-Discriminant-Analysis]], [[Exploratory-Data-Analysis|Exploratory-Data-Analysis]], Correlation-vs-Causality
|
||||
- **Raw Source:** 10_Wiki/Topics/AI/Multivariate-Analysis.md
|
||||
### 매 family
|
||||
- **PCA**: max variance projection (eigen of Σ).
|
||||
- **FA (Factor Analysis)**: latent factors + idiosyncratic noise (X = ΛF + ε).
|
||||
- **CCA**: max correlation between two variable sets.
|
||||
- **LDA**: discriminant axes (between-class vs within-class scatter).
|
||||
- **MANOVA**: multivariate generalization of ANOVA (Wilks Λ, Pillai trace).
|
||||
- **MDS**: distance-preserving embedding.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. EDA on tabular data (correlation heatmap, biplot).
|
||||
2. Feature engineering before tree models or MLP.
|
||||
3. Genomics (gene expression PCA / FA).
|
||||
4. Marketing segmentation (cluster + biplot).
|
||||
5. Psychometrics (factor structure of survey).
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### PCA — full pipeline
|
||||
```python
|
||||
from sklearn.decomposition import PCA
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
X_std = StandardScaler().fit_transform(X)
|
||||
pca = PCA(n_components=0.95) # keep 95% variance
|
||||
Z = pca.fit_transform(X_std)
|
||||
print(pca.explained_variance_ratio_.cumsum())
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
# Biplot
|
||||
loadings = pca.components_.T * np.sqrt(pca.explained_variance_)
|
||||
plt.scatter(Z[:,0], Z[:,1], alpha=0.3)
|
||||
for i, name in enumerate(feature_names):
|
||||
plt.arrow(0, 0, loadings[i,0]*3, loadings[i,1]*3, color='r')
|
||||
plt.text(loadings[i,0]*3.2, loadings[i,1]*3.2, name)
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Factor Analysis with rotation
|
||||
```python
|
||||
from sklearn.decomposition import FactorAnalysis
|
||||
fa = FactorAnalysis(n_components=3, rotation='varimax')
|
||||
fa.fit(X_std)
|
||||
print(fa.components_) # loadings
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### CCA (cross-modal)
|
||||
```python
|
||||
from sklearn.cross_decomposition import CCA
|
||||
cca = CCA(n_components=2)
|
||||
cca.fit(X_view1, X_view2)
|
||||
U, V = cca.transform(X_view1, X_view2)
|
||||
# diag(corr(U, V)) = canonical correlations
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Linear Discriminant Analysis
|
||||
```python
|
||||
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
|
||||
lda = LinearDiscriminantAnalysis(n_components=2)
|
||||
Z = lda.fit_transform(X_std, y) # supervised projection
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### MANOVA via statsmodels
|
||||
```python
|
||||
from statsmodels.multivariate.manova import MANOVA
|
||||
maov = MANOVA.from_formula('y1 + y2 + y3 ~ group', data=df)
|
||||
print(maov.mv_test()) # Wilks, Pillai, Hotelling, Roy
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Mahalanobis distance (multivariate outliers)
|
||||
```python
|
||||
import numpy as np
|
||||
mu = X.mean(axis=0)
|
||||
S_inv = np.linalg.inv(np.cov(X, rowvar=False))
|
||||
def mahal(x):
|
||||
d = x - mu
|
||||
return np.sqrt(d @ S_inv @ d)
|
||||
# threshold: chi2.ppf(0.975, df=p)
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Variance compression unsupervised | PCA |
|
||||
| Latent structure interpretation | Factor Analysis (with rotation) |
|
||||
| Two correlated groups of vars | CCA |
|
||||
| Supervised projection | LDA |
|
||||
| Group-mean comparison (multivariate) | MANOVA |
|
||||
| Distance-only data | MDS |
|
||||
| Outlier detection multivariate | Mahalanobis / Min Cov Det |
|
||||
|
||||
**기본값**: 매 EDA에 PCA + correlation heatmap, 매 supervised에 LDA, 매 latent factor에 FA + varimax.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Statistics]] · [[Linear-Algebra]]
|
||||
- 변형: [[PCA]] · [[Factor-Analysis]] · [[CCA]] · [[LDA]] · [[MANOVA]]
|
||||
- 응용: [[EDA]] · [[Feature-Engineering]] · [[Biostatistics]]
|
||||
- Adjacent: [[Dimensionality-Reduction]] · [[t-SNE]] · [[UMAP]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 EDA narrative generation (PCA biplot 해석), factor labeling, MANOVA result writeup.
|
||||
**언제 X**: 매 actual decomposition computing (numpy/sklearn use).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **No standardization**: 매 PCA before scaling → 매 large-magnitude vars dominate.
|
||||
- **PCA on nonlinear**: 매 swiss-roll에 매 PCA 매 사용 → 매 t-SNE/UMAP/Isomap 매 사용.
|
||||
- **FA without rotation**: 매 unrotated factors 매 interpret 어려움 — 매 varimax/promax 적용.
|
||||
- **MANOVA assumption**: 매 multivariate normality + equal cov 매 검증 X → wrong p-values.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Johnson & Wichern "Applied Multivariate", Hardle & Simar).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full MVA toolkit (PCA/FA/CCA/LDA/MANOVA) |
|
||||
|
||||
Reference in New Issue
Block a user