rpart模型在插入符号中崩溃为零分裂

时间:2013-10-30 19:41:51

标签: r r-caret rpart cart-analysis

我使用rpart在插入符包中使用选择函数的oneSE选项运行回归树分析。当我这样做时,我经常会得到一个零分裂的模型。它表明没有任何模型比任何模型更好。这应该发生吗?

以下是一个例子:

# set training controls
tc <- trainControl("repeatedcv", repeats=100, selectionFunction="oneSE", num=10)

# run the model
mod <- train(yvar ~ ., data=dat, method="rpart", trControl=tc)

# it runs.....
# look at the cptable of the final model
printcp(mod$finalModel)

这是模型输出:

> mod
No pre-processing
Resampling: Cross-Validation (10 fold, repeated 100 times) 

Summary of sample sizes: 81, 79, 80, 80, 80, 80, ... 

Resampling results across tuning parameters:

  cp      RMSE   Rsquared  RMSE SD  Rsquared SD
  0.0245  0.128  0.207     0.0559   0.23       
  0.0615  0.127  0.226     0.0553   0.241      
  0.224   0.123  0.193     0.0534   0.195      

RMSE was used to select the optimal model using  the one SE rule.
The final value used for the model was cp = 0.224. 

这是printcp的输出:

Variables actually used in tree construction:

character(0)
Root node error: 1.4931/89 = 0.016777
n= 89 
CP nsplit rel error
1 0.22357      0         1

但是,如果我只是直接在rpart中运行模型,我可以看到更大的未修剪的树被修剪为上面所谓的更简约的模型:

unpruned = rpart(yvar ~., data=dat)
printcp(unpruned)

Regression tree:
rpart(formula = yvar ~ ., data = dat)

Variables actually used in tree construction:
[1] c.n.ratio Fe.ppm    K.ppm     Mg.ppm    NO3.ppm  

Root node error: 1.4931/89 = 0.016777

n= 89 

    CP nsplit rel error xerror    xstd
1 0.223571      0   1.00000 1.0192 0.37045
2 0.061508      2   0.55286 1.1144 0.33607
3 0.024537      3   0.49135 1.1886 0.38081
4 0.010539      4   0.46681 1.1941 0.38055
5 0.010000      6   0.44574 1.2193 0.38000

Caret [我认为]正试图找到最小的树,其RMSE在具有最低RMSE的模型的1SD内。这类似于Venebles和Ripley所倡导的1-SE方法。在这种情况下,即使它没有解释力,它似乎仍然卡在没有分裂的情况下挑选模型。

这是对的吗?这个可以吗?似乎应该有一个规则来阻止选择没有拆分的模型。

1 个答案:

答案 0 :(得分:0)

尝试删除selectionFunction="oneSE"

这应该用尽可能小的错误来识别深度。在这样做时,选择最小观察到的RMSE存在“优化偏差”的可能性,但我发现在实践中它很小。

最高

相关问题