[英]How to extract linear models regression coefficients when using M5 with the train function of the caret package?
I have built a M5 regression model tree using the train function of the caret
package. 我使用
caret
包的训练函数构建了M5 回归模型树。 I am trying to extract the linear model coefficients
for each model of the tree. 我正在尝试为树的每个模型提取
linear model coefficients
。
The final model is called m5tune
. 最终模型称为
m5tune
。 I tried to look into m5tune$finalModel
but I did not find it. 我试图研究
m5tune$finalModel
但没有找到。 The coeff()
function does not seem to work either... coeff()
函数似乎也不起作用...
Using this approach, you can get the correlation coefficient. 使用这种方法,可以获得相关系数。 Please the data is only representative.
请提供数据仅供参考。
library(Rweka)
iris1<-as.data.frame(iris)
set.seed(456)
mytrain<-createDataPartition(iris$Sepal.Length,p=0.8,list=F)
trainme<-iris[mytrain,]
mymodel<-train(Sepal.Length~.,trainme,trControl=trainControl(method="cv",number=5),method="M5",
metric="MAE")
Simply calling this gives you the correlation coefficient. 简单地调用它就可以得到相关系数。
summary(mymodel)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.