[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,65 +2,144 @@
|
||||
id: wiki-2026-0508-sensitivity-analysis
|
||||
title: Sensitivity Analysis
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-SEAN-001]
|
||||
aliases: [Sobol, Morris, SALib, Feature Importance]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.94
|
||||
tags: [auto-reinforced, sensitivity-Analysis, Robustness, uncertainty, Optimization, decision-making]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [statistics, ml-interpretability, uncertainty]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: python
|
||||
framework: SALib / scikit-learn / SHAP
|
||||
---
|
||||
|
||||
# [[Sensitivity-Analysis|Sensitivity-Analysis]]
|
||||
# Sensitivity Analysis
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "무엇이 가장 치명적인가?: 결과값에 영향을 주는 여러 변수 중 하나를 살짝 바꿔봤을 때 전체 결과가 얼마나 요동치는지 측정하여, 우리가 어떤 변수를 가장 금이야 옥이야 관리해야 하는지 알려주는 시스템의 '약점 탐지기'."
|
||||
## 매 한 줄
|
||||
> **"매 input 변동이 output 의 어디에 얼마나 영향?"**. 매 Sobol indices (variance decomposition), Morris elementary effects (screening), 그리고 ML interpretability (SHAP, permutation importance) 모두 매 sensitivity analysis 의 family. 매 2026 default: SALib (classic SA) + SHAP (ML model).
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
민감도 분석(Sensitivity-Analysis)은 입력 변수의 변화가 출력 변수에 미치는 영향을 분석하는 기법입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **목적**:
|
||||
* **Prioritization**: 결과에 가장 큰 영향을 주는 'Key factors'를 식별. ([[Pareto-Principle|Pareto-Principle]]와 연결)
|
||||
* **Risk Mitigation**: 어떤 수치가 틀렸을 때 시스템이 붕괴되는지 미리 파악. (Risk-[[Management|Management]]와 연결)
|
||||
* **Model Validation**: 모델의 반응이 상식적인지(변수를 높였는데 결과가 이상하게 가는지) 확인.
|
||||
2. **왜 중요한가?**:
|
||||
* 모든 변수에 똑같은 에너지를 쏟는 것은 비효율적이며, 민감도 분석은 승패를 결정짓는 핵심 20%에 집중하게 돕기 때문임. ([[Efficiency|Efficiency]] 극대화)
|
||||
### 매 Local vs Global
|
||||
- **Local**: gradient at one point (∂y/∂x). 매 빠르지만 nonlinear 모델 misleading.
|
||||
- **Global**: full input space sample. 매 Sobol/Morris/FAST. 매 정직.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 한 번에 하나씩만 바꿔보는 '단순 주입 정책'이었으나, 현대 정책은 수만 번의 시뮬레이션 정책(Monte Carlo)을 돌려 변수들 간의 복합적인 민감도 정책을 분석하는 방향으로 진화함(RL Update).
|
||||
- **정책 변화(RL Update)**: AI 프롬프트 엔지니어링 정책에서도 특정 단어 하나가 답변의 퀄리티 정책을 얼마나 바꾸는지 테스트하는 'prompt Sensitivity Analysis'가 성능 최적화 정책의 필수 과정이 됨.
|
||||
### 매 Method 분류
|
||||
- **Screening (Morris)**: 매 cheap, identify important factors among many. r·(k+1) runs.
|
||||
- **Variance-based (Sobol)**: S1 (first-order), ST (total). 매 N·(2k+2) Saltelli sample.
|
||||
- **Regression-based**: standardized regression coefficients (SRC).
|
||||
- **ML feature importance**: permutation, SHAP, integrated gradients.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Pareto-Principle|Pareto-Principle]], [[Risk-Management|Risk-Management]], [[Efficiency|Efficiency]], [[Optimization|Optimization]], [[Analysis|Analysis]], [[Decision Theory|Decision Theory]]
|
||||
- **Modern Tech/Tools**: What-If Tool, Tornado ch[[Arts|Arts]], Monte Carlo simulations.
|
||||
---
|
||||
### 매 응용
|
||||
1. Engineering tolerance — 매 어느 parameter 가 yield drop.
|
||||
2. Climate/epidemiology model — input uncertainty propagation.
|
||||
3. ML model debug — 매 feature 가 prediction drive.
|
||||
4. Hyperparameter search prior — 매 important hp 만 tune.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Sobol indices (SALib)
|
||||
```python
|
||||
from SALib.sample import saltelli
|
||||
from SALib.analyze import sobol
|
||||
import numpy as np
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
problem = {
|
||||
'num_vars': 3,
|
||||
'names': ['x1', 'x2', 'x3'],
|
||||
'bounds': [[0, 1]] * 3,
|
||||
}
|
||||
param_values = saltelli.sample(problem, 1024)
|
||||
Y = np.array([model(*row) for row in param_values])
|
||||
Si = sobol.analyze(problem, Y)
|
||||
print(Si['S1'], Si['ST']) # first-order + total
|
||||
```
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Morris screening
|
||||
```python
|
||||
from SALib.sample.morris import sample
|
||||
from SALib.analyze import morris
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
X = sample(problem, N=100, num_levels=4)
|
||||
Y = np.array([model(*r) for r in X])
|
||||
Mi = morris.analyze(problem, X, Y, num_levels=4)
|
||||
print(Mi['mu_star'], Mi['sigma']) # importance, nonlinearity
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### Permutation importance (sklearn)
|
||||
```python
|
||||
from sklearn.inspection import permutation_importance
|
||||
r = permutation_importance(model, X_val, y_val, n_repeats=20, random_state=0)
|
||||
for i in r.importances_mean.argsort()[::-1]:
|
||||
print(f"{features[i]}: {r.importances_mean[i]:.3f} ± {r.importances_std[i]:.3f}")
|
||||
```
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### SHAP for any model
|
||||
```python
|
||||
import shap
|
||||
explainer = shap.TreeExplainer(xgb_model) # or shap.Explainer for general
|
||||
sv = explainer(X_val)
|
||||
shap.plots.beeswarm(sv) # global
|
||||
shap.plots.waterfall(sv[0]) # local
|
||||
```
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### Tornado plot (one-at-a-time)
|
||||
```python
|
||||
base = model(**defaults)
|
||||
deltas = []
|
||||
for k, (lo, hi) in bounds.items():
|
||||
lo_y = model(**{**defaults, k: lo})
|
||||
hi_y = model(**{**defaults, k: hi})
|
||||
deltas.append((k, hi_y - lo_y))
|
||||
deltas.sort(key=lambda x: abs(x[1]), reverse=True)
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### Variance decomposition w/ ANOVA
|
||||
```python
|
||||
import statsmodels.api as sm
|
||||
from statsmodels.formula.api import ols
|
||||
m = ols('y ~ x1 + x2 + x3 + x1:x2', data=df).fit()
|
||||
print(sm.stats.anova_lm(m, typ=2))
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 100+ inputs, screen first | Morris |
|
||||
| <20 inputs, full ranking | Sobol |
|
||||
| ML black-box | SHAP / permutation |
|
||||
| Linear-ish model | SRC |
|
||||
| One-shot intuition | Tornado |
|
||||
|
||||
**기본값**: SALib Sobol (simulation), SHAP (ML model).
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Statistics]] · [[Uncertainty-Quantification]]
|
||||
- 변형: [[SHAP]] · [[Permutation-Importance]]
|
||||
- 응용: [[Hyperparameter-Tuning]] · [[Model-Debugging]]
|
||||
- Adjacent: [[Bayesian-Inference]] · [[Monte-Carlo]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: simulation/model에서 어느 input이 결과 좌우하는지 정량화. ML feature 중요도 ranking.
|
||||
**언제 X**: input 간 강한 correlation 존재 — Sobol 가정 깨짐. Conditional SA / Shapley 사용.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **OAT only**: one-at-a-time 은 interaction 놓침.
|
||||
- **Sample 너무 작음**: Sobol N<512 → 매우 noisy estimate.
|
||||
- **Correlated inputs 무시**: independence 가정 violation.
|
||||
- **SHAP = causal**: SHAP 는 attribution, causality 아님.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Saltelli 2010, SALib docs, scikit-learn inspection).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Sobol/Morris/SHAP unified treatment |
|
||||
|
||||
Reference in New Issue
Block a user