Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用系数法从模型中提取方程_Python_R_Regression - Fatal编程技术网

Python 用系数法从模型中提取方程

Python 用系数法从模型中提取方程,python,r,regression,Python,R,Regression,我有一个简单的问题,我用下面的方法运行一个线性模型 model1 <- lm(output ~. , data=df) 我希望输出的形式 output=1.1*var1 + 1.2*var2+.... 你应该看看equatiomatic软件包 下面的代码应该可以解决您的问题,我使用iris作为一个例子 remotes::install_github("datalorax/equatiomatic") library(equatiomatic) mod1 <- lm(Petal.W

我有一个简单的问题,我用下面的方法运行一个线性模型

model1 <- lm(output ~. , data=df)
我希望输出的形式

output=1.1*var1 + 1.2*var2+....

你应该看看equatiomatic软件包

下面的代码应该可以解决您的问题,我使用iris作为一个例子

remotes::install_github("datalorax/equatiomatic")
library(equatiomatic)
mod1 <- lm(Petal.Width~.-Species, data= iris)
extract_eq(mod1, use_coefs = TRUE, wrap=TRUE,fix_signs = FALSE,ital_vars = TRUE,terms_per_line = 4)

谢谢你,我刚刚添加了LoadLineThis outputs Latex,所以它只在将输出转换为PDF的上下文中有用,例如在rmarkdown输出中。在某种程度上,OP并没有明确说明他们在做什么。有更好的方法吗?我很乐意了解:为什么这是标记python?你想得到哪种类型的输出,一个字符串?
remotes::install_github("datalorax/equatiomatic")
library(equatiomatic)
mod1 <- lm(Petal.Width~.-Species, data= iris)
extract_eq(mod1, use_coefs = TRUE, wrap=TRUE,fix_signs = FALSE,ital_vars = TRUE,terms_per_line = 4)