매개변수 vs 하이퍼파라미터

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

Dr. Shirin Elsinghorst

Senior Data Scientist

강사 소개

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

"하이퍼"파라미터 vs 모델 매개변수

  • 예제 데이터셋을 살펴봅시다:
head(breast_cancer_data)
# A tibble: 6 x 11
  diagnosis concavity_mean symmetry_mean fractal_dimension perimeter_se smoothness_se
  <chr>              <dbl>         <dbl>             <dbl>        <dbl>         <dbl>
1 M                 0.300          0.242            0.0787         8.59       0.00640
2 M                 0.0869         0.181            0.0567         3.40       0.00522
3 M                 0.197          0.207            0.0600         4.58       0.00615
4 M                 0.241          0.260            0.0974         3.44       0.00911
  • 간단한 선형 모델을 구축합니다.
R에서 하이퍼파라미터 튜닝

기초부터 시작: 선형 모델의 매개변수

# Create linear model
linear_model <- lm(perimeter_worst ~ fractal_dimension_mean, data = breast_cancer_data)
# Get coefficients
summary(linear_model)$coefficients
                       Estimate Std. Error t value Pr(>|t|)    
(Intercept)              167.60      25.91   6.469  3.9e-09 ***
fractal_dimension_mean  -926.39     392.86  -2.358   0.0204 *
R에서 하이퍼파라미터 튜닝

기초부터 시작: 선형 모델의 매개변수

  • 모델 매개변수는 훈련 중에 적합(즉, 탐색)됩니다.
  • 모델 적합 또는 훈련의 결과입니다.

  • 선형 모델에서는 계수를 탐색합니다.

linear_model$coefficients
(Intercept) fractal_dimension_mean 
   167.5972              -926.3866 
  • 모델의 기울기y절편으로 이해할 수 있습니다.
R에서 하이퍼파라미터 튜닝

선형 모델의 계수

ggp <- ggplot(data = breast_cancer_data, 
              aes(x = fractal_dimension_mean, y = perimeter_worst)) +
        geom_point(color = "grey")

ggp + geom_abline(slope = linear_model$coefficients[2], intercept = linear_model$coefficients[1])

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

선형 모델에서의 매개변수 vs 하이퍼파라미터

  • 기억하세요: 모델 매개변수는 훈련 중에 적합(즉, 탐색)됩니다. 모델 적합 또는 훈련의 결과입니다.

  • 하이퍼파라미터는 훈련 전에 설정됩니다.

  • 훈련이 어떻게 진행되는지를 지정합니다.
args(lm)
help(lm)
?lm

linear_model <- lm(perimeter_worst ~ fractal_dimension_mean,
                   data = breast_cancer_data,
                   method = "qr")
R에서 하이퍼파라미터 튜닝

머신러닝에서의 매개변수 vs 하이퍼파라미터

선형 모델에서:

  • 계수는 적합 중에 탐색됩니다.

 

  • method는 적합 전에 설정하는 옵션입니다.

머신러닝에서는:

  • 훈련 중 최적화되는 신경망의 가중치와 편향 => 모델 매개변수.
  • 학습률, 가중치 감쇠, 랜덤 포레스트의 트리 수 등 조정 가능한 옵션 => 하이퍼파라미터.
R에서 하이퍼파라미터 튜닝

하이퍼파라미터를 튜닝하는 이유

  • 판타지 풋볼 선수 ~ 하이퍼파라미터
  • 선수 포지션 ~ 하이퍼파라미터
  • 최적의 선수·포지션 조합 찾기 ~ 최적의 하이퍼파라미터 조합 탐색

https://pixabay.com/photo-1493087/

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

연습해 봅시다!

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

Preparing Video For Download...