我正在尝试完成应用预测建模 (Max Kuhn) 第 7 章中的练习 3,它使用袋装 MARS 模型。我使用的代码直接来自这里的解决方案: 第 7 章解决方案
但是,当我训练 bagEarth 模型时:
meatBMARS <- train(x = absorpTrain, y = proteinTrain,
+ method = "bagEarth",
+ trControl = ctrl,
+ tuneLength = 25,
+ B = 20)
我得到错误:
Something is wrong; all the RMSE metric values are missing:
RMSE Rsquared
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :25 NA's :25
Error in train.default(x = absorpTrain, y = proteinTrain, method = "bagEarth", :
Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
> warnings()
Warning messages:
1: In eval(expr, envir, enclos) :
predictions failed for Fold01.Rep1: degree=1, nprune=32 Error in eval(expr, envir, enclos) :
could not find function "bagEarth.default"
2: In eval(expr, envir, enclos) :
predictions failed for Fold02.Rep1: degree=1, nprune=32 Error in eval(expr, envir, enclos) :
could not find function "bagEarth.default"
3: In eval(expr, envir, enclos) :
predictions failed for Fold03.Rep1: degree=1, nprune=32 Error in eval(expr, envir, enclos) :
could not find function "bagEarth.default"
4: In eval(expr, envir, enclos) :
predictions failed for Fold04.Rep1: degree=1, nprune=32 Error in eval(expr, envir, enclos) :
could not find function "bagEarth.default
...
被训练的数据是来自 caret 包的 tecator 数据,分为训练集和测试集:
> data(tecator)
> set.seed(1029)
> inMeatTraining <- createDataPartition(endpoints[, 3], p = 3/4, list= FALSE)
> absorpTrain <- absorp[ inMeatTraining,]
> absorpTest <- absorp[-inMeatTraining,]
> proteinTrain <- endpoints[ inMeatTraining, 3]
> proteinTest <- endpoints[-inMeatTraining,3]
> ctrl <- trainControl(method = "repeatedcv", repeats = 5)
有关数据集的更多信息:
> str(absorpTrain)
num [1:163, 1:100] 2.62 2.83 2.82 2.79 3.01 ...
> str(proteinTrain)
num [1:163] 16.7 13.5 20.7 15.5 13.7 13.7 19.3 17.7 17.7 12.5 ...
我已经安装并加载了 earth 包,所以我不确定为什么会这样。
任何建议将不胜感激。