简体   繁体   English

将M5与插入符号包的训练函数一起使用时,如何提取线性模型回归系数?

[英]How to extract linear models regression coefficients when using M5 with the train function of the caret package?

I have built a M5 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.

相关问题 在插入符号包中使用训练函数时线性回归的误差 - error in linear regression while using the train function in caret package 使用前向回归和/或LARS从插入符号中的R的训练函数中检索系数 - Retrieve coefficients from R's train function in caret using forward regression and/or LARS 如何使用插入符包 train() 和 varImp() 在 R 中显示逻辑回归的系数值和变量重要性 - How to show the coefficient values and variable importance for logistic regression in R using caret package train() and varImp() 如何使用 `R` `cem` package 在 CEM 匹配数据上估计线性回归 model 的系数? - How to estimate coefficients for linear regression model on CEM matched data using `R` `cem` package? 如何使用gbm提取逻辑回归中的系数? - how to extract coefficients in logistic regression using gbm? Rcaret包中的火车功能 - The train function in R caret package 如何提取使用mlr包生成的模型的超级学习者/元学习者系数? - How to extract Super Learner / meta learner coefficients of models produced using the mlr package? 运行线性回归时在 R 中使用 train() 函数时出错 - Error using train() function in R while running linear regression 在插入符号 package 中:train() 在使用度数 = 2 的 gamLoess 时崩溃 - In caret package: train() crashes when using gamLoess with degree=2 使用lmodel2包从精简主轴回归模型中获得回归系数 - Obtaining regression coefficients from reduced major axis regression models using lmodel2 package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM