एडैप्टिव रिसैंपलिंग

R में Hyperparameter Tuning

Dr. Shirin Elsinghorst

Senior Data Scientist

Adaptive Resampling क्या है?

Grid Search

  • हाइपरपैरामीटर की सभी कॉम्बिनेशंस compute की जाती हैं.

Random Search

  • हाइपरपैरामीटर कॉम्बिनेशंस के रैंडम सबसेट compute किए जाते हैं.

→ सबसे अच्छी कॉम्बिनेशन का मूल्यांकन अंत में होता है.

Adaptive Resampling

  • जो कॉम्बिनेशंस अच्छा करती हैं, उनके आस-पास के मानों के साथ हाइपरपैरामीटर कॉम्बिनेशंस को फिर से सैंपल किया जाता है.
  • इसलिए Adaptive Resampling तेज़ और अधिक कुशल है!

"Futility Analysis in the Cross-Validation of Machine Learning Models." Max Kuhn; ARXIV 2014

R में Hyperparameter Tuning

caret में एडैप्टिव रिसैंपलिंग

trainControl: method = "adaptive_cv" + search = "random" + adaptive =

  • min: प्रति हाइपरपैरामीटर न्यूनतम resamples

  • alpha: हाइपरपैरामीटर हटाने के लिए कॉन्फिडेंस स्तर

  • method: रैखिक मॉडल के लिए "gls" या Bradley-Terry के लिए "BT"

  • complete: अगर TRUE है तो पूरा resampling सेट बनाता है

fitControl <- trainControl(method = "adaptive_cv",
                             adaptive = list(min = 2, alpha = 0.05, 
                                             method = "gls", complete = TRUE),
                             search = "random")
R में Hyperparameter Tuning
  • trainControl() + tuneLength = x
fitControl <- trainControl(method = "adaptive_cv", number = 3, repeats = 3,
                           adaptive = list(min = 2, 
                                           alpha = 0.05, 
                                           method = "gls", 
                                           complete = TRUE),
                             search = "random")

tic() set.seed(42) gbm_model_voters_adaptive <- train(turnout16_2016 ~ ., data = voters_train_data, method = "gbm", trControl = fitControl, verbose = FALSE, tuneLength = 7) toc()
1239.837 sec elapsed
R में Hyperparameter Tuning

एडैप्टिव रिसैंपलिंग

gbm_model_voters_adaptive
...
Resampling results across tuning parameters:
  shrinkage   interaction.depth  n.minobsinnode  n.trees  Accuracy   Kappa       Resamples
  0.07137493   5                  6              4152     0.9564654  0.02856571  9        
  0.08408739   5                 14               674     0.9547185  0.02098853  4        
  0.28552325   8                 15              3209     0.9568141  0.03024238  3        
  0.33663932  10                 13              2595     0.9571130  0.04250979  9        
  0.54251480   3                 24              3683     0.9482171  0.03568586  2        
  0.56406870   7                 25              4685     0.9549898  0.05284333  5        
  0.58695763   8                 24              1431     0.9520286  0.02742592  2        
Accuracy was used to select the optimal model using the largest value.
The final values used for the model were n.trees = 2595,
interaction.depth = 10, shrinkage = 0.3366393 and n.minobsinnode = 13.
R में Hyperparameter Tuning

चलिए कोडिंग करें!

R में Hyperparameter Tuning

Preparing Video For Download...