【发布时间】:2017-04-11 19:57:15
【问题描述】:
我一直在尝试使用 Caret for R 中“frbs”包中的“SBC”方法来拟合模型。我在 SO 中看到了针对不同包的类似问题并尝试了解决方案,但它们似乎不起作用就我而言。我提供了一个代码 sn-p 用于使用 iris 数据集的可重现性。
library(caret)
data("iris")
grid<-expand.grid(r.a = c(0.5),
eps.high = c(0.5),
eps.low = c(0))
Fit <- train(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width, data = iris,
method = "SBC",
# trControl = fitControl,
tuneGrid=grid,
verbose = TRUE)
Fit$results
得到的错误是:
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 :3 NA's :3
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
我检查了警告(),它显示“Resample17 的模型拟合失败:ra=0.5,eps.high=0.5,eps.low=0 frbs.learn 中的错误(data.train = structure(c(3.5, 3, 3.2, 3.1, 3.4, 3.4, : ....."。我什至尝试过单独安装 frbs 包。此外,我确保变量的类不是因素,即使对于我的数据也是如此。
我的问题是如何修复此错误以及为什么会发生此错误。任何帮助将不胜感激。
提前致谢。
【问题讨论】:
-
不可重现,它在我的机器上按预期工作
-
尝试将
predictor变量强制转换为factor类型,看看是否可行? -
@sandipan 那么这个错误可能与机器有关吗?同样的代码也在我同事的系统上运行。还有什么我可以尝试的吗?
-
@Aramis7d 由于该方法用于回归,将其转换为因子显示错误
Error in train.default(x, y, weights = w, ...) : wrong model type for classification -
可能,您可能想比较一下您和您同事的 R 版本/插入符号版本/OS 版本等。