我想编写使用train
的caret package
函数训练回归模型的e函数,并绘制重采样曲线。我的问题是没有显示绘图,也没有抛出错误。这应该是一个可重复的例子:
trFun <- function(){
library( caret )
library( mlbench )
data( BostonHousing )
lmFit <- train(
medv ~ .,
data=BostonHousing,
method="pls"
)
#trellis.par.set( caretTheme() )
plot( lmFit )
lmFit
}
fit <- trFun()
plot( fit )
所以plot( lmfit )
里面的trFun
没有绘制任何东西,而plot( fit )
在函数之外就是情节。 trellis.par.set( caretTheme() )
声明似乎无关紧要。
我的问题是:如何在trFun
中绘制重新采样配置文件?
这是sessionInfo()
输出:
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 tools_3.4.3 yaml_2.1.16