scaling이 중요할 때
linear model, distance-based model(kNN, k-means), 신경망은 scaled feature 필요. tree-based model은 안 필요해 — 순서만 신경 써. 대칭 분포엔 StandardScaler, outlier 있으면 RobustScaler, bounded input 필요하면 MinMaxScaler.
categorical encoding
- One-hot — low-cardinality(~30 이하), 어떤 모델과도 호환.
- Ordinal — 순서가 의미 있고 모델이 tree-based일 때.
- Target encoding — cardinality 높고 모델이 tree-based일 때, 항상 CV fold 안에서 적용.
- Hashing — 메모리가 제약이고 collision 견딜 수 있을 때.
pipeline 배치
scaler와 encoder는 pipeline 안에 살아. training만 보고 fit, validation과 production에 동일하게 apply. raw row의 단일 entrypoint로 column transformer를 유지해. pipeline에 없는 노트북 cell에서 preprocess 절대 하지 마.