#I find the same model hyperparameters will have different results depending on # ordering of the tune options even when setting a seed before running. # For example, if I use a grid search for the best hyperparameters, and then # fit an additional model with the same tune, there are different results. library(WeightIt) data(lalonde) lalonde_formula - as.formula(treat ~ age + educ + re75 + nodegree + married) # Searching for the optimal tree fit. set.seed(123) model1 - weightit(lalonde_formula, data=lalonde, method=gbm, shrinkage=c(.01,0.05), bag.fraction=1, interaction.depth=3, n.trees=10000, criterion=smd.mean, estimand=ATT) model1$info$best.tune # The optimal fit has been found. Now I redo this same tree fit using the # same hyperparameters. Note that the seed is reset as well. set.seed(123) model2 - weightit(lalonde_formula, data=lalonde, method=gbm, shrinkage=c(0.05), bag.fraction=1, interaction.depth=3, n.trees=321, criterion=smd.mean, estimand=ATT) # Ideally the same smd.mean would be found in this as the best tune from model1. # However, the result is different. subset(model2$info$tree.val,tree==321) # The order of parameters given, will change the relative performance of the tunes. set.seed(123) model3 - weightit(lalonde_formula, data=lalonde, method=gbm, shrinkage=c(.05,0.01), bag.fraction=1, interaction.depth=3, n.trees=10000, criterion=smd.mean, estimand=ATT) # This model is the exact same model as in model1 but the best tuning parameters are # completely different. model3$info$best.tune # An example of the set seed picking up where previously finished that occurs # inside each trees in my view. Apologies if this is stating the obvious but had not # realised this occurs until someone showed me. set.seed(123) rnorm(2) rnorm(2) set.seed(123) rnorm(4)