
v1 비율 은 각 성분의 개별 비율. 실제 실무에서는:
"분산의 95% 를 보존하려면 몇 개 성분이 필요한가?"
이런 기준을 자동으로 찾는 게 자연스러움. sklearn PCA(n_components=0.95) 가 동일하게 동작.
면 "분산 95% 를 설명하는 가장 작은 차원".
함수 auto_k_pca(X, variance_threshold) 를 완성하세요.
X shape (N, D), variance_threshold ∈ [0, 1] (넘어도 D 로 capped).(k, cumulative) — k Python int, cumulative shape (D,) 전체 누적 비율 배열.np.searchsorted(cumulative, threshold) + 1 로 가장 먼저 초과하는 인덱스.| # | 이름 | 검증 |
|---|---|---|
| 1 | 반환 (int, (D,)) | |
| 2 | cumulative 단조 증가, 마지막 = 1 | |
| 3 | threshold=1.0 → k=D | |
| 4 | threshold=0.0 → k=1 | |
| 5 | threshold=0.95 데이터에서 일관된 k | |
| 6 | cumulative[k-1] >= threshold, cumulative[k-2] < threshold (중간) | |
| 7 | 강한 첫 성분 데이터: threshold=0.9 → k=1 |
코드를 작성하고 Run 을 눌러보세요.