Reputation: 2837
My end goal, with data in the matrix below, is training a number of models across a grid of different lambdas and alphas, using the glmnet
method. Perhaps there is another way to approach this tuning problem as well.
x <- Macro[1:13, 3:21]
x <- as.matrix(x)
y <- Macro[1:13, 2:2]
y <- as.matrix(y)
myfit <- caret::train(x, y,
method = "glmnet",
tuneGrid = expand.grid(.alpha = seq(.05, 1, length = 15),
.lambda = c((5:10)/10)))
The above code returns the following error:
Error in train.default(x, y, method = "glmnet", tuneGrid = expand.grid(.alpha = seq(0.05, : Metric RMSE not applicable for classification models
Upvotes: 2
Views: 1010
Reputation: 673
The problem is that your response variable y
is a matrix but it should be "A numeric or factor vector containing the outcome for each sample"
according to the documentation of train
. Therefore, you just have to remove y <- as.matrix(y)
from your code and it will work.
Upvotes: 1