샘플 외 오류 측정치

R의 caret로 배우는 Machine Learning

Zach Mayer

Data Scientist at DataRobot and co-author of caret

샘플 외 오류

  • 과적합 없이 일반화되는 모델이 필요함
  • 새 데이터에서도 잘 작동하나요?
  • 새 데이터(테스트 세트)로 성능 평가
    • 머신러닝의 핵심 통찰
    • 샘플 내 검증은 과적합을 거의 보장
  • caret과 본 과정의 주요 목표: 과적합 방지
R의 caret로 배우는 Machine Learning

예시: 샘플 외 RMSE

# Fit a model to the mtcars data
data(mtcars)
model <- lm(mpg ~ hp, mtcars[1:20, ])
# Predict out-of-sample
predicted <- predict(
  model, mtcars[21:32, ], type = "response"
)
# Evaluate error
actual <- mtcars[21:32, "mpg"]
sqrt(mean((predicted - actual) ^ 2))
5.507236
R의 caret로 배우는 Machine Learning

샘플 내 RMSE와 비교

# Fit a model to the full dataset
model2 <- lm(mpg ~ hp, mtcars)
# Predict in-sample
predicted2 <- predict(
  model, mtcars, type = "response"
)
# Evaluate error
actual2 <- mtcars[, "mpg"]
sqrt(mean((predicted2 - actual2) ^ 2))
3.74

샘플 외 RMSE 5.5와 비교.

R의 caret로 배우는 Machine Learning

연습해 봅시다!

R의 caret로 배우는 Machine Learning

Preparing Video For Download...