Caret Train Function in R – Does glmnet Cross-Validate for Both Alpha and Lambda?

caretcross-validationglmnetmachine learningr

Does the R caret package cross-validate over both alpha and lambda for the glmnet model?
Running this code,

eGrid <- expand.grid(.alpha = (1:10) * 0.1, 
                     .lambda = (1:10) * 0.1)

Control <- trainControl(method = "repeatedcv",repeats = 3,verboseIter =TRUE)

netFit <- train(x =train_features, y = y_train,
          method = "glmnet",
          tuneGrid = eGrid,
          trControl = Control)

The training log looks like this.

Fold10.Rep3: alpha=1.0, lambda=NA 

What does lambda=NA mean?

Best Answer

train does tune over both.

Basically, you only need alpha when training and can get predictions across different values of lambda using predict.glmnet. Maybe a value of lambda = "all" or something else would be more informative.

Max