python - 从具有系数的模​​型中提取方程

标签 python r regression

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

model1 <- lm(output ~. , data=df)

我得到一些输出,我想直接提取线性方程,而不是查看原始形式的输出

我知道扫帚包我最擅长的是

   library(broom)
    tidy(mod1)

我想要表单输出

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

最佳答案

您应该看看等式包 ( https://github.com/datalorax/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)

关于python - 从具有系数的模​​型中提取方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57917369/

相关文章:

python - 在 Python "' 模块中将 html 读取到数据框时出错模块'对象没有属性 '_base'“

python - 循环http客户端python,扭曲

r - glm后如何返回分数向量?

r - 将图例添加到具有重叠密度图的 ggplot 直方图

根据不同列中的值替换 data.frame 列中的值

python - Python scikit learn 中分类和回归分数的差异

r - 逻辑回归替代解释

r - 计算 DFFITS 作为回归中杠杆和影响的诊断

python - 如何防止 Python 脚本强制退出?

python - 重命名没有列名的 pandas 数据框的列