我想重复以下几行代码:
x.mat <- as.matrix(train.df[,predictors])
y.class <- train.df$Response
cv.lasso.fit <- cv.glmnet(x = x.mat, y = y.class,
family = "binomial", alpha = 1, nfolds = 10)
...使用插入符号包,但它不起作用:
trainControl <- trainControl(method = "cv",
number = 10,
# Compute Recall, Precision, F-Measure
summaryFunction = prSummary,
# prSummary needs calculated class probs
classProbs = T)
modelFit <- train(Response ~ . -Id, data = train.df,
method = "glmnet",
trControl = trainControl,
metric = "F", # Optimize by F-measure
alpha=1,
family="binomial")
无法识别参数“alpha”,并且“模型拟合在每次折叠中失败”。
我做错了什么?非常感谢帮助。感谢。
答案 0 :(得分:5)
尝试使用tuneGrid。例如如下:
tuneGrid=expand.grid(
.alpha=1,
.lambda=seq(0, 100, by = 0.1))