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

Drift Monitoring

~28 min · drift, monitoring, production

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

세 가지가 drift

  • Input drift — feature 분포 shift (예: 마케팅 캠페인이 user mix 바꿈).
  • Output drift — input 안정해 보여도 prediction 분포 shift.
  • Concept drift — feature와 target 관계 바뀜 (세상 바뀜).

각각 어떻게 monitor

Input drift: reference window 대비 feature 별 distance metric(Kolmogorov-Smirnov, Population Stability Index). Output drift: predicted 확률의 moving 분포. Concept drift: labeled production data 위 metric의 rolling window.

retraining 트리거

각 metric에 threshold 설정하고 alerting system 통과. cadence(weekly가 sane default)로 retrain 하고 drift alert fire 시 ad-hoc. 새 모델 promote 전 항상 shadow-deploy.

Code

두 window 비교용 PSI·python
import numpy as np

def psi(reference, current, bins=10):
    edges = np.quantile(reference, np.linspace(0, 1, bins + 1))
    edges[0], edges[-1] = -np.inf, np.inf
    p_ref, _ = np.histogram(reference, bins=edges)
    p_cur, _ = np.histogram(current, bins=edges)
    p_ref = np.clip(p_ref / p_ref.sum(), 1e-6, None)
    p_cur = np.clip(p_cur / p_cur.sum(), 1e-6, None)
    return ((p_cur - p_ref) * np.log(p_cur / p_ref)).sum()

for col in numeric_cols:
    score = psi(reference[col], current[col])
    if score > 0.20:  # >0.10 = caution, >0.25 = serious
        print(f"⚠️  PSI {col} = {score:.3f}")
predicted-probability shift로 output drift·python
from scipy.stats import ks_2samp

stat, pval = ks_2samp(reference_probs, current_probs)
if pval < 0.01:
    alert("output distribution drifted", stat=stat, pval=pval)

External links

Exercise

모델에 가장 중요한 feature 5개 골라. training window와 가장 최근 2주 production data 사이 PSI 계산. PSI > 0.10인 feature마다, 원인에 대한 한 문장 가설.

Progress

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

댓글 0

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

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