mlr로 하이퍼파라미터 평가하기

R에서 하이퍼파라미터 튜닝

Dr. Shirin Elsinghorst

Data Scientist

평가를 통해 알 수 있는 것:

  • 다양한 하이퍼파라미터가 모델 성능에 미치는 영향
  • 어떤 하이퍼파라미터가 성능에 특히 강하거나 약한 영향을 주는지
  • 하이퍼파라미터 탐색이 수렴했는지, 즉 최적의 하이퍼파라미터 조합(또는 근사치)을 찾았다고 합리적으로 볼 수 있는지
R에서 하이퍼파라미터 튜닝

복습

getParamSet("classif.h2o.deeplearning")

param_set <- makeParamSet( makeDiscreteParam("hidden", values = list(one = 10, two = c(10, 5, 10))), makeDiscreteParam("activation", values = c("Rectifier", "Tanh")), makeNumericParam("l1", lower = 0.0001, upper = 1), makeNumericParam("l2", lower = 0.0001, upper = 1) )
ctrl_random <- makeTuneControlRandom(maxit = 50)
holdout <- makeResampleDesc("Holdout")
task <- makeClassifTask(data = knowledge_train_data, target = "UNS") lrn <- makeLearner("classif.h2o.deeplearning", predict.type = "prob", fix.factors.prediction = TRUE) lrn_tune <- tuneParams(lrn, task, resampling = holdout, control = ctrl_random, par.set = param_set)
R에서 하이퍼파라미터 튜닝
lrn_tune

generateHyperParsEffectData(lrn_tune, partial.dep = TRUE)
튜닝 결과:
최적 파라미터: hidden=one; activation=Rectifier; l1=0.541; l2=0.229
mmce.test.mean=0.160000

HyperParsEffectData: 하이퍼파라미터: hidden,activation,l1,l2 측정치: mmce.test.mean 옵티마이저: TuneControlRandom 중첩 CV 사용: FALSE [1] "Partial dependence requested" 데이터 스냅샷: hidden activation l1 l2 mmce.test.mean iteration exec.time 1 one Rectifier 0.75940339 0.9956819 0.40 1 0.883 2 one Rectifier 0.16701526 0.2948697 0.40 2 0.836 3 one Rectifier 0.88458832 0.9228281 0.70 3 0.830 4 two Rectifier 0.48840740 0.7276899 0.70 4 0.820 5 one Tanh 0.87114452 0.9971268 0.40 5 0.835 6 two Tanh 0.07412213 0.3841913 0.44 6 0.830
R에서 하이퍼파라미터 튜닝

하이퍼파라미터 튜닝 결과 시각화

hyperpar_effects <- generateHyperParsEffectData(lrn_tune, partial.dep = TRUE)
plotHyperParsEffect(hyperpar_effects, partial.dep.learn = "regr.randomForest",
                    x = "l1", y = "mmce.test.mean", z = "hidden",
                    plot.type = "line")

R에서 하이퍼파라미터 튜닝

이제 직접 해보세요!

R에서 하이퍼파라미터 튜닝

Preparing Video For Download...