插入号训练方法抱怨有些地方不对劲;缺少所有RMSE指标值 [英] Caret train method complains Something is wrong; all the RMSE metric values are missing
问题描述
在很多情况下,尝试拟合gbm
或rpart
模型时,都会出现此错误.最终,我能够使用公开可用的数据一致地重现它.我注意到使用CV(或重复的Cv)时会发生此错误.当我不使用任何健身控件时,我不会收到此错误.有人能阐明为什么我总是不断出错的情况吗?
On numerous occasions I've been getting this error when trying to fit a gbm
or rpart
model. Finally I was able to reproduce it consistently using publicly available data. I have noticed that this error happens when using CV (or repeated cv). When I don't use any fit control I don't get this error. Can some shed some light one why I keep getting error consistently.
fitControl= trainControl("repeatedcv", repeats=5)
ds = read.csv("http://www.math.smith.edu/r/data/help.csv")
ds$sub = as.factor(ds$substance)
rpartFit1 <- train(homeless ~ female + i1 + sub + sexrisk + mcs + pcs,
tcControl=fitControl,
method = "rpart",
data=ds)
推荐答案
有一个错字,应该是trControl
而不是tcControl
.并且当以tcControl
形式提供参数时,caret
将此参数传递给rpart并抛出错误,因为该选项从不可用.
There is a typo, it should be trControl
instead of tcControl
. And when the argument is provided as tcControl
, caret
passes this to rpart and this throws an error because this option was never available.
我想这回答了您的问题,即在尝试进行交叉验证时为什么会出现此错误.
I guess this answers your question of why you get this error when you try to have a cross-validation in training.
下面是它的工作方式:
library(caret)
library(mosaicData)
data(HELPrct)
ds = HELPrct
fitControl= trainControl(method="repeatedcv",times=5)
ds$sub = as.factor(ds$substance)
rpartFit1 <- train(homeless ~ female + i1 + sub + sexrisk + mcs + pcs,
trControl=fitControl,
method = "rpart",
data=ds[complete.cases(ds),])
rpartFit1
CART
117 samples
6 predictor
2 classes: 'homeless', 'housed'
No pre-processing
Resampling: Cross-Validated (10 fold)
Summary of sample sizes: 105, 105, 105, 106, 105, 106, ...
Resampling results across tuning parameters:
cp Accuracy Kappa
0.00000000 0.5280303 -0.03503032
0.01190476 0.5280303 -0.03503032
0.07142857 0.5977273 -0.02970604
Accuracy was used to select the optimal model using the largest value.
The final value used for the model was cp = 0.07142857.
这篇关于插入号训练方法抱怨有些地方不对劲;缺少所有RMSE指标值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!