Choose optimal model for training using R