在 Windows 7、R 3.0.2、caret 6.0-21 上插入符号 train() 出现致命错误 [英] Fatal error with train() in caret on Windows 7, R 3.0.2, caret 6.0-21

查看:33
本文介绍了在 Windows 7、R 3.0.2、caret 6.0-21 上插入符号 train() 出现致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在插入符号中使用 train() 来适应分类模型,但我遇到了某种未处理的异常,并且在 R 控制台中输出任何错误信息之前,我的 R 会话崩溃了.
Windows 错误:

I am trying to use train() in caret to fit a classification model, but I'm hitting some kind of unhandled exception and my R session crashes before outputting any error information in the R console.
Windows error:

R for Windows 终端前端已停止工作

R for Windows terminal front-end has stopped working

我正在运行 Windows 7、R 3.0.2、插入符号 6.0-21,并尝试在 32/64 版本的 R、R Studio 和直接在 R 控制台中运行它,并且得到相同的结果每次.

I am running Windows 7, R 3.0.2, caret 6.0-21, and have tried running this on both 32/64 versions of R, in R Studio and also directly in the R console, and am getting the same results each time.

这是我的训练要求:

library("AppliedPredictiveModeling")
library("caret")

data("AlzheimerDisease")
data <- data.frame(predictors, diagnosis)

tuneGrid <- expand.grid(interaction.depth = 1:2, n.trees = 100, shrinkage = 0.1)
trainControl <- trainControl(method = "cv", number = 5, verboseIter = TRUE)

gbmFit <- train(diagnosis ~ ., data = data, method = "gbm", trControl = trainControl, tuneGrid = tuneGrid)

使用此参数网格不再有错误:

There are no more errors using this parameter grid instead:

tuneGrid <- expand.grid(interaction.depth = 1, n.trees = 100:101, shrinkage = 0.1)

但是,我仍然在 ValidDeviance 列中获取所有 nan .这正常吗?

However, I am still getting all nans in the ValidDeviance column. Is this normal?

注意:我原来的问题已经解决,这是评论部分的延续.在注释部分格式化代码块是不可读的,所以我把它张贴在这里.这不再是关于插入符号的问题,而是关于 gbm.

Note: My original problem is resolved, and this is a continuation from the comments section. Formatting blocks of code in the comments section is unreadable so I'm posting it up here. This is no longer a question regarding caret, but gbm instead.

但是,我仍然遇到问题,使用指定了 cv.folds 的单个预测器直接调用 gbm.代码如下:

I am still having issues, however, with direct calls to gbm using a single predictor with cv.folds specified. Here is the code:

library("AppliedPredictiveModeling")
library("caret")

data("AlzheimerDisease")
diagnosis <- as.numeric(diagnosis)
diagnosis[diagnosis == 1] <- 0
diagnosis[diagnosis == 2] <- 1
data <- data.frame(diagnosis, predictors[, 1])
gbmFit <- gbm(diagnosis ~ ., data = data, cv.folds = 5)

同样,这可以在不指定 cv.folds 的情况下工作,但使用它会返回错误:

Again, this works without specifying cv.folds but with it, returns an error:

Error in checkForRemoteErrors(val) :  5 nodes produced errors; first error: incorrect number of dimensions

推荐答案

method = 'gbm' 与单个模型(即 nrow(tuneGrid) == 1).我即将发布一个新版本,所以我会在那个版本中修复这个问题.

It is a bug that occurs when method = 'gbm' is used with a single model (i.e. nrow(tuneGrid) == 1). I'm about to release a new version, so I will fix this in that version.

一个旁注...看起来你想做分类.在这种情况下, y 应该是一个因子(并且您不应该只使用整数作为类),否则它将进行回归.这些更改暂时有效:

One side note... it looks like you want to do classification. In that case, y should be a factor (and you shouldn't use only integers as the classes) otherwise it will be doing regression. These changes will work for now:

 y <- factor(paste("Class", y, sep = ""))

 tuneGrid <- expand.grid(interaction.depth = 1, 
                         n.trees = 100:101, 
                         shrinkage = 0.1)

谢谢,

最大

这篇关于在 Windows 7、R 3.0.2、caret 6.0-21 上插入符号 train() 出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆