C.W.K.
Stream
Lesson 03 of 07 · published

Overfitting과 Underfitting

~26 min · overfitting, underfitting, diagnostics

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

두 실패 모양

Overfitting: training loss 작고 validation loss 훨씬 큼. 모델이 noise 외움. Underfitting: training과 validation loss 둘 다 나쁨. 모델이 용량 부족이거나 잘못된 표현. 두 loss를 같은 chart에 plot 해서 진단.

각 실패에 맞서는 손잡이

실패손잡이
Overfitting데이터 더, regularization 더, 더 단순한 모델, early stopping, dropout, feature 줄이기
Underfitting용량 더, feature 개선, interaction 더, regularization 줄이기

learning curve

데이터 크기 증가에 따른 training과 validation loss를 plot. 둘 다 떨어지면 데이터 더 필요. validation flat인데 training 떨어지면 용량 더 안 도와 — regularization이나 feature 필요. 30초 진단.

Code

learning curve 진단·python
from sklearn.model_selection import learning_curve
import numpy as np

sizes, train_scores, val_scores = learning_curve(
    pipe, X, y, cv=5, scoring="average_precision",
    train_sizes=np.linspace(0.1, 1.0, 8), n_jobs=-1
)
print("train mean:", train_scores.mean(axis=1))
print("val mean:  ", val_scores.mean(axis=1))
boosting 모델을 위한 early stopping·python
import lightgbm as lgb

model = lgb.LGBMClassifier(n_estimators=2000, learning_rate=0.03)
model.fit(
    X_tr, y_tr, eval_set=[(X_val, y_val)],
    callbacks=[lgb.early_stopping(50)]
)

External links

Exercise

best 모델의 learning curve plot. 모양에서 데이터 더 / 용량 더 / regularization 더 중 더 큰 payoff 결정. 셋 다 말고 그거 하나만 다음에 해.

Progress

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

댓글 0

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

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