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

Feature, Label, Example, Dataset

~30 min · features, labels, tabular-data

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

dataset도 계약이야

supervised dataset은 그냥 테이블이 아냐. 각 row가 example, feature는 prediction 시점에 알려진 정보, label은 train 중에 모델이 배우도록 허용된 답이야. dataset 설계의 가장 어려운 부분은 어느 column이 어떤 역할인지 정직하게 정하는 거.

column마다 던질 세 질문

  1. 이 column이 비즈니스적으로 뭘 의미하나? 한 문장으로 못 적으면 미래의 버그.
  2. 이 값은 언제 알려지나? prediction 후에만 존재하면 leakage.
  3. 혹시 target을 우연히 인코딩하고 있지는 않나? hash-encoded ID, post-event status, 지원 통화 카운트, 환불 금액 — 흔한 범인들.

스키마를 가드로

작은 column-audit DataFrame은 고전 ML에서 가장 leverage 큰 습관 중 하나야. 각 column을 feature / label / identifier / leakage risk / post-event metadata로 마킹하게 강제해. 일단 이게 있으면, 새 column이 들어올 때 역할을 골라야만 pipeline에 들어와.

Code

churn dataset용 column-audit 테이블·python
import pandas as pd

audit = pd.DataFrame([
    {"column": "customer_id", "role": "identifier", "known_at_prediction": True, "use": False},
    {"column": "plan_tier", "role": "feature", "known_at_prediction": True, "use": True},
    {"column": "tickets_last_30d", "role": "feature", "known_at_prediction": True, "use": True},
    {"column": "days_since_signup", "role": "feature", "known_at_prediction": True, "use": True},
    {"column": "cancel_reason_text", "role": "post_event", "known_at_prediction": False, "use": False},
    {"column": "refund_amount", "role": "post_event", "known_at_prediction": False, "use": False},
    {"column": "churned", "role": "label", "known_at_prediction": False, "use": "target"},
])
feature_cols = audit.loc[audit["use"] == True, "column"].tolist()
audit을 모델로 들어가는 유일한 길로·python
X = df[feature_cols].copy()
y = df["churned"]
assert "cancel_reason_text" not in X.columns, "leakage column slipped through"

External links

Exercise

실제(혹은 가상) churn / fraud dataset에 대해 column-audit DataFrame을 작성해. 모든 column을 feature / label / identifier / post-event / leakage 로 마킹해. column_audit.csv로 저장하고 train 스크립트에서 reference 해.

Progress

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

댓글 0

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

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