C.W.K.
Stream
Lesson 02 of 04 · published

Dimensionality Reduction

~28 min · pca, umap, tsne

Level 0Scout
0 XP0/48 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

줄이는 두 이유

Compression: signal 캐리하는 component만 유지하면 많은 모델이 빨라짐. Visualization: 사람은 200D가 아니라 2D scatter plot 읽음. 진짜 필요한 일에 따라 기법 골라.

큰 셋

  • PCA — linear, 빠름, deterministic. compression과 preprocessing step에 탁월.
  • UMAP — non-linear, local과 global 구조 합리적으로 보존. 오늘날 visualization의 go-to.
  • t-SNE — non-linear, 아름다운 local 구조, global distance에 대해 오해 가능. 오래되었지만 cluster inspection에 여전히 유용.

cardinal 실수

UMAP이나 t-SNE coordinate를 downstream 모델 feature로 쓰지 마. visualization 위해 설계됨, stable representation 아님. PCA는 OK, UMAP/t-SNE는 X.

Code

explained variance 체크 동반한 compression용 PCA·python
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import numpy as np

Xs = StandardScaler().fit_transform(X)
pca = PCA(n_components=0.95, svd_solver="full").fit(Xs)
print("components kept:", pca.n_components_)
print("explained variance:", np.cumsum(pca.explained_variance_ratio_)[-1].round(3))
2D visualization을 위한 UMAP·python
import umap

reducer = umap.UMAP(n_neighbors=15, min_dist=0.1, random_state=7)
embedding = reducer.fit_transform(Xs)
# embedding.shape == (n, 2) — for plotting only

External links

Exercise

scaled feature matrix를 PCA(n_components=0.95)로 reduce. best 모델을 원본 feature와 PCA feature에 train. CV score와 train/predict latency 비교. compression이 ship 할 가치 있는지 결정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.