Eis*_*sen 3 r machine-learning tidymodels
有没有办法在 tidy 模型中获得逻辑回归的标准误差和 p 值?
我可以通过下面的代码获得系数..但我想计算每个特征的优势比,我还需要标准误差..
glm.fit <-
logistic_reg(mode = "classification") %>%
set_engine(engine = "glm") %>%
fit(Species ~ ., data = iris)
glm.fit$fit$coefficients
Run Code Online (Sandbox Code Playgroud)
通常你可以通过调用summary()
glm 对象来做到这一点,但我在这里尝试使用 tidymodels。
你可以试试:
library(broom)
library(tidymodels)
glm.fit <-
logistic_reg(mode = "classification") %>%
set_engine(engine = "glm") %>%
fit(Species ~ ., data = iris)
tidy(glm.fit)
# A tibble: 5 x 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 16.9 457457. 0.0000370 1.00
2 Sepal.Length -11.8 130504. -0.0000901 1.00
3 Sepal.Width -7.84 59415. -0.000132 1.00
4 Petal.Length 20.1 107725. 0.000186 1.00
5 Petal.Width 21.6 154351. 0.000140 1.00
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
561 次 |
最近记录: |